Django templates mix static text with variables and tags
Answer: A Django template is a text document (or Python string) marked up with the Django template language. It holds the static parts of the desired HTML and special syntax for dynamic content.
Variables, tags, context
The main constructs are variables and tags. A template is rendered with a context. Rendering replaces variables with values looked up in the context and executes tags. Everything else is output as is. Variables are surrounded by {{ and }}.
A project may use one or several template engines, including the built-in Django template language and Jinja2.
The Engine
django.template.engine.Engine compiles a Template from template code (from_string) or from a template name (get_template), handling template inheritance recursively.
See also
Claims
- id: C1 claim: A template is rendered with a context. source: S1 evidence: "A template is rendered with a context."
- id: C2 claim: A project can use one or several template engines. source: S1 evidence: "A Django project can be configured with one or several template engines"
- id: C3 claim: Engine.from_string compiles a template from code. source: S2 evidence: "Return a compiled Template object for the given template code,"
- id: C4 claim: Engine.get_template compiles a template from a name. source: S2 evidence: "Return a compiled Template object for the given template name,"
Sources
- [S1] The Django template language. Django docs. https://docs.djangoproject.com/en/6.1/topics/templates/ . License: BSD-3-Clause. Accessed 2026-11-10.
- [S2] django.template.engine.Engine. Django source. https://github.com/django/django/blob/stable/6.1.x/django/template/engine.py . License: BSD-3-Clause. Accessed 2026-11-10.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: Django documentation and source (django/django): Copyright (c) Django Software Foundation and individual contributors; BSD-3-Clause (https://raw.githubusercontent.com/django/django/stable/6.1.x/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Django docs, The Django template language, BSD-3-Clause (django/django); Django source, django.template.engine.Engine, BSD-3-Clause (django/django). Notices: Django documentation and source (django/django): Copyright (c) Django Software Foundation and individual contributors; BSD-3-Clause (https://raw.githubusercontent.com/django/django/stable/6.1.x/LICENSE).
Cite this
iinventedlight. 2026. "Django templates mix static text with variables and tags." iinventedlight Library, iil:note:s181evmn, version of 2026-11-10. https://iinventedlight.com/library/notes/django-templates/. License: CC-BY-4.0.
@misc{iil_note_s181evmn,
author = {{iinventedlight}},
title = {{Django templates mix static text with variables and tags}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-10},
url = {https://iinventedlight.com/library/notes/django-templates/},
note = {Permanent ID iil:note:s181evmn. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/django-templates.md.