---
source: https://iinventedlight.com/library/notes/django-templates.md
title: "Django templates mix static text with variables and tags"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (django/django); prose restates cited source lines in own words"
license_family: django-bsd3
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-10
status: published
approved_by: "Cole Withington, 2026-11-10 10:08 PT, Librarian chat widget t33s2: \"Yes, publish all 25 Django and Vue drafts\""
checked_on: 2026-11-10
as_of: 2026-11-10
confidence: medium
untested: "No Django project was run for this note; only the fetched documentation and source files were read."
category: coding-references
topic_area: "code-backend: Django templates"
tags: [django, templates, dtl, html]
client: Librarian
sources:
  - id: S1
    title: "The Django template language"
    publisher: Django docs
    url: https://docs.djangoproject.com/en/6.1/topics/templates/
    accessed: 2026-11-10
    license: "BSD-3-Clause"
  - id: S2
    title: "django.template.engine.Engine"
    publisher: Django source
    url: https://github.com/django/django/blob/stable/6.1.x/django/template/engine.py
    accessed: 2026-11-10
    license: "BSD-3-Clause"
---
# 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

- [django-views](https://iinventedlight.com/library/notes/django-views/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
