django-dynamic-template
Django app for content-type–scoped dynamic templates: store DTL fragments in the database, address them with a named_id slug (django-namedid), inject optional related querysets and a structured object dict into each fragment.
Requirements
- Python ≥ 3.10
- Django ≥ 3.2
- django-namedid (declared in
pyproject.toml; VCS pin until stable wheels are available)
Installation
From the repository root (editable install recommended for local work):
pip install -e .
Add the app and dependencies you need:
INSTALLED_APPS = [
# ...
"dynamic_template",
]
Optional: django-boosted (admin preview), django-richtextfield (TinyMCE-style widget) — see pyproject.toml [project.optional-dependencies] dev.
Concepts
| Piece | Role |
|---|---|
DynamicTemplate |
label, content_type, named_id, template (richtext), plus model_fields, annotate_fields, fields shaping object in the fragment |
DynamicRelationContext |
Related queryset (manager + filters), same three JSON fields per row; rows are tuples of dicts in the fragment |
{% dyntpl %} |
Loads a template by named_id, merges context, evaluates relation contexts, then replaces object with a plain dict |
model_fields: ORM column names (empty → all concrete fields on the model).annotate_fields: list of annotation aliases already on the queryset / instance — this app does not call.annotate(); your manager or view must provide them.fields: extra Python names resolved withgetattr(@property, class attributes, methods).
Filters on relations: filter_spec (resolved from object + template context) and filter_literal (static ORM kwargs). See docs/purpose.md for full detail.
Template tag
{% load dyntpl %}
{% dyntpl "my-block-named-id" %}
{% dyntpl tpl_id obj=article %}
{% dyntpl tpl_id ctype=Product obj=product %}
obj=: must match the template’scontent_type.ctype=: disambiguates when the samenamed_idexists for several models.- Other keyword arguments are merged into the inner fragment context.
In the fragment, use {{ object.name }}, {% for row in article %}{{ row.title }}{% endfor %}, {{ rows|length }} (not .count on querysets).
Settings (optional)
# Import path to a widget class for the template field in admin
DYNAMIC_TEMPLATE_RICHTEXT_WIDGET = "djrichtextfield.widgets.RichTextWidget"
Development
pytest
pyproject.toml sets DJANGO_SETTINGS_MODULE=tests.settings and pythonpath=["src"].
Apply migrations for the bundled test project:
PYTHONPATH=src DJANGO_SETTINGS_MODULE=tests.settings python manage.py migrate
More detail: docs/ (purpose.md, structure.md, development.md).
License
MIT
Metadata
Release files for django-dynamic-template 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_dynamic_template-0.3.1.tar.gz | 29.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_dynamic_template-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.5 kB
Release files / django_dynamic_template-0.3.1.tar.gz
| Download URL | django_dynamic_template-0.3.1.tar.gz |
|---|---|
| Size | 29.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ed6577d1f91fab7e7bd677b8e9cb431818f5ae8af0cfe38145adfff3b1226a2
|
|
BLAKE2b-256 checksum How to use checksums |
8b1296ddbec8deed949698613d4d7f4e74545be2975464494a3d53120a35c4fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logRelease files / django_dynamic_template-0.3.1-py3-none-any.whl
| Download URL | django_dynamic_template-0.3.1-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7d5dd6caa1bfef6415b1a8db57a7058368277b9ae612abbcd532647e16c17bf
|
|
BLAKE2b-256 checksum How to use checksums |
52c4949aa847f3f2294f34d0f5bafdfac35bfd494082a426fbec2da51c056bcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logSecurity for django-dynamic-template 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for django_dynamic_template-0.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.