Django Templates 5.2

Last reviewed Sep 24, 2026

Export as PDF

Prompt Details

Prompt Composition

3prompts
  1. Python 3155 lines · 3.8K tokens
  2. Django 5.2157 lines · 4.1K tokens
  3. Django Templates 5.282 lines · 3K tokens
Total394 lines · 10.9K tokens

CWE Coverage

  • 20
  • 23
  • 36
  • 59
  • 73
  • 78
  • 79
  • 89
  • 95
  • 117
  • 201
  • 203
  • 208
  • 209
  • 214
  • 250
  • 287
  • 295
  • 307
  • 319
  • 328
  • 338
  • 347
  • 352
  • 367
  • 379
  • 384
  • 409
  • 416
  • 426
  • 427
  • 434
  • 470
  • 488
  • 502
  • 521
  • 524
  • 532
  • 601
  • 611
  • 613
  • 614
  • 639
  • 640
  • 674
  • 732
  • 770
  • 772
  • 776
  • 778
  • 798
  • 807
  • 829
  • 830
  • 862
  • 915
  • 916
  • 918
  • 942
  • 1004
  • 1021
  • 1104
  • 1275
  • 1333
  • 1336
  • 1395

Prompt Preview

Apply the Django 5.2 prompt first. These rules cover Django Template Language in Django 5.2.17 on maintained Python 3.10–3.14 micro releases.

Template trust and loading

  • Treat templates, inheritance parents, included fragments, tag libraries, filters, loaders, and backend configuration as trusted application code. Keep tenant-editable content out of template search paths and pass it as data to fixed templates.
  • Map request-selectable themes, layouts, template_name values, {% include %}, {% extends %}, and template-name lists through a server-owned allowlist authorized for the current tenant.
  • Keep DIRS, APP_DIRS, and loader order deployment-controlled; earlier directories and installed applications can shadow templates with the same name. Namespace application templates to avoid unintended overrides.
  • Protect template roots and their symlinks from untrusted writes. filesystem.Loader uses a lexical safe_join() check, not symlink confinement; enforce path and tenant boundaries explicitly in custom loaders.
  • Register libraries through reviewed applications or fixed libraries and builtins mappings; adding a library to builtins exposes its tags and filters without {% load %}.
  • Account for the default cached.Loader when custom loaders vary their source by tenant: use tenant-qualified template names or separate engines and caches, because its key does not include the request or tenant automatically.
  • Rebuild affected engines or restart workers when template sources, loader order, libraries, or security configuration change; the