python-requests Django Framework Core Concepts - Templates

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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!.



Got any python-requests Question?