In django, a template is simply a file that contains special tags which may be replaced by data from the view.
The canonical template example would be:
<strong>Hello {{ name }}, I am a template!</strong>
Here, the string {{ name }}
identifies a placeholder that may be replaced by a context.
To render this template from a view, we can pass in the value as a dictionary:
from django.shortcuts import render
def simple_view(request):
return render(request, 'template.html', {'name': 'Jim'})
Once this view is rendered, the resulting HTML will be Hello Jim, I am a template!.