Templates:
==========
web pages/web apps ==> load/open with browser
web page ==> collection of web elements.
web elements ==> HTML elements
like:
Headings
, , , , and
Paragraph
etc.
==> Templates can used to add all the html code instead to write in "views.py".
==> After writing, we should render that template to our app.
Creation of Template:
=====================
Select your App
create directory/folder with name "templates"
with templates folder:
we need to add sub folder with your app name.
within the sub-folder:
we need to crate the html file.
Syntax:
file-name.html
add the code into the html file
Render the html file into our Django app:
=========================================
in views.py:
===========
from Django.template import loader
def index(request):
item_list = Item.objects.all()
template = loader.get_template("html file location")
context = {
}
return HttpResponse(template.rende(context,request))
==> run the server
python manage.py runserver
==> copy the server url
and add your page to url navigation
ex: http://127.0.01:8000/item/