The Definitive Guide to Django 2nd Edition-Using the Template System

Let’s dive into Django’s template system so you can see how it works—but we’re not yet going to integrate it with the views that we created in the previous chapter. Our goal here is to show you how the system works independent of the rest of Django. (Usually you’ll use the template system within a Django view, but we want to make it clear that the template system is just a Python library that you can use anywhere, not just in Django views.)
Here is the most basic way you can use Django’s template system in Python code:
1. Create a Template object by providing the raw template code as a string.
2. Call the render() method of the Template object with a given set of variables (the con-
text). This returns a fully rendered template as a string, with all of the variables and
template tags evaluated according to the context.