Render Template In Django Part4 Django Tutorials

preview_player
Показать описание


Join :

In the last part, we have created a hello world application, and there we have returned a simple h2 tag to the request. but in the real world there will be lots of lines present so it's not the right way to write all the HTML code inside the view so we can use render method to render the HTML page.
Updating views to render the template

For rendering a template we are going to use render method it is automatically imported while creating the app so we don't have to import that if it's not been imported then import it first and then, use it with the return statement like below.

def home(request):


This render function takes the request as the first argument and the HTML page path from the template folder in the second argument.

Now we will create the template(i.e the HTML page what the render function is rendering for.

NOTE: You can access your hello world page on "/hello_world". In localhost:8000/hello_world

Complete Playlist:

Thank You
Keep Learning & Keep Growing

#TWP #DjangoTutorials #LearnOnLockdown
Рекомендации по теме
Комментарии
Автор

i didn't understand if i want my Django Templates+Database to work in charset=iso-8859-1 what are the steps that i should make plz?

CharbelNasr-bwgq
visit shbcf.ru