As we have seen earlier, the Context is a mapping of variable names to values. When the template is rendered, these values are made available to the template engine and fill in "the holes" in your templates by replacing variables with their respective values.
Technically, the Context is a class in Django that we instantiate before rendering a template. A context is a mapping of a single variable name to a value. When we render the template, we are usually registering multiple contexts, or multiple mappings of variable names to values. Don't get hung up on the semantics. When we're talking about context, just think about the variables that are made available to the template.
To use the Context, we import the Context
class from django.template.Context
. When we instantiate it, we can pass a dictionary of variable names as an optional argument.
To experiment with the Context, we can launch the Django interactive shell by running these commands:
$ cd /projects/mycompany
$...