← All notes

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

Sources

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

Permanent ID: iil:note:s181evmn

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.},
}

Markdown

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.