
Yr: {{yr}}
Any worth inside double curly braces in a template is handled as a variable. Every thing else is handled actually.
Modify myapp/views.py to appear like this:
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Whats up, world!")
def yr(request, yr):
information = {'yr':yr}
return render(request, 'myapp/yr.html', information)
The render operate—a Django “shortcut” (a mixture of a number of built-ins for comfort)—takes the prevailing request object, seems to be for the template myapp/yr.html within the listing of obtainable template areas, and passes the dictionary information to it as context for the template. The template makes use of the dictionary as a namespace for variables used within the template. On this case, the variable {{yr}} within the template is changed with the worth for the important thing yr within the dictionary information (that’s, information["year"]).
The quantity of processing you are able to do on information inside Django templates is deliberately restricted. Django’s philosophy is to implement the separation of presentation and enterprise logic each time potential. Thus, you may loop by means of an iterable object, and you may carry out if/then/else assessments, however modifying the info inside a template is discouraged.

