django-templates-pro 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_templates_pro-0.3.0/.gitignore +17 -0
- django_templates_pro-0.3.0/CHANGELOG.md +70 -0
- django_templates_pro-0.3.0/LICENSE +21 -0
- django_templates_pro-0.3.0/PKG-INFO +184 -0
- django_templates_pro-0.3.0/README.md +134 -0
- django_templates_pro-0.3.0/SETUP.md +591 -0
- django_templates_pro-0.3.0/docs/admin.md +111 -0
- django_templates_pro-0.3.0/docs/commands.md +96 -0
- django_templates_pro-0.3.0/docs/concepts.md +217 -0
- django_templates_pro-0.3.0/docs/development.md +82 -0
- django_templates_pro-0.3.0/docs/editor.md +140 -0
- django_templates_pro-0.3.0/docs/formatting.md +157 -0
- django_templates_pro-0.3.0/docs/html-contract.md +43 -0
- django_templates_pro-0.3.0/docs/index.md +40 -0
- django_templates_pro-0.3.0/docs/installation.md +109 -0
- django_templates_pro-0.3.0/docs/operations.md +78 -0
- django_templates_pro-0.3.0/docs/quickstart.md +142 -0
- django_templates_pro-0.3.0/docs/rendering.md +247 -0
- django_templates_pro-0.3.0/docs/samples.md +319 -0
- django_templates_pro-0.3.0/docs/security.md +100 -0
- django_templates_pro-0.3.0/docs/settings.md +45 -0
- django_templates_pro-0.3.0/docs/template-types.md +187 -0
- django_templates_pro-0.3.0/docs/troubleshooting.md +92 -0
- django_templates_pro-0.3.0/example/README.md +90 -0
- django_templates_pro-0.3.0/example/demo/__init__.py +0 -0
- django_templates_pro-0.3.0/example/demo/admin.py +29 -0
- django_templates_pro-0.3.0/example/demo/apps.py +7 -0
- django_templates_pro-0.3.0/example/demo/constants.py +12 -0
- django_templates_pro-0.3.0/example/demo/docs.py +132 -0
- django_templates_pro-0.3.0/example/demo/doctemplate_types.py +211 -0
- django_templates_pro-0.3.0/example/demo/management/__init__.py +0 -0
- django_templates_pro-0.3.0/example/demo/management/commands/__init__.py +0 -0
- django_templates_pro-0.3.0/example/demo/management/commands/seed_demo.py +154 -0
- django_templates_pro-0.3.0/example/demo/markdown.py +265 -0
- django_templates_pro-0.3.0/example/demo/migrations/0001_initial.py +184 -0
- django_templates_pro-0.3.0/example/demo/migrations/__init__.py +0 -0
- django_templates_pro-0.3.0/example/demo/models.py +93 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/bank-details.html +1 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/company-letterhead.html +2 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/customer-details.html +2 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/page-footer-he.html +1 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/page-footer.html +1 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/payment-terms.html +3 -0
- django_templates_pro-0.3.0/example/demo/samples/blocks/signature.html +2 -0
- django_templates_pro-0.3.0/example/demo/samples/manifest.json +197 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/employment-certificate.html +10 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/invoice-hebrew.html +16 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/invoice-modern.html +6 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/invoice-standard.html +13 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/order-confirmation.html +8 -0
- django_templates_pro-0.3.0/example/demo/samples/templates/welcome-letter.html +11 -0
- django_templates_pro-0.3.0/example/demo/static/demo/favicon.png +0 -0
- django_templates_pro-0.3.0/example/demo/static/demo/favicon_OLD.svg +6 -0
- django_templates_pro-0.3.0/example/demo/static/demo/logo.png +0 -0
- django_templates_pro-0.3.0/example/demo/static/demo/logo_OLD.png +0 -0
- django_templates_pro-0.3.0/example/demo/static/demo/northwind-theme.css +11 -0
- django_templates_pro-0.3.0/example/demo/templates/demo/base.html +45 -0
- django_templates_pro-0.3.0/example/demo/templates/demo/docs.html +79 -0
- django_templates_pro-0.3.0/example/demo/templates/demo/gallery.html +12 -0
- django_templates_pro-0.3.0/example/demo/templates/demo/index.html +29 -0
- django_templates_pro-0.3.0/example/demo/templates/demo/user_letter.html +19 -0
- django_templates_pro-0.3.0/example/demo/views.py +136 -0
- django_templates_pro-0.3.0/example/exampleproject/__init__.py +0 -0
- django_templates_pro-0.3.0/example/exampleproject/settings.py +85 -0
- django_templates_pro-0.3.0/example/exampleproject/urls.py +19 -0
- django_templates_pro-0.3.0/example/exampleproject/wsgi.py +6 -0
- django_templates_pro-0.3.0/example/manage.py +14 -0
- django_templates_pro-0.3.0/example/run_demo.py +100 -0
- django_templates_pro-0.3.0/frontend/README.md +16 -0
- django_templates_pro-0.3.0/frontend/package-lock.json +1900 -0
- django_templates_pro-0.3.0/frontend/package.json +29 -0
- django_templates_pro-0.3.0/frontend/scripts/contract.mjs +53 -0
- django_templates_pro-0.3.0/frontend/src/editor.css +216 -0
- django_templates_pro-0.3.0/frontend/src/editor.js +1102 -0
- django_templates_pro-0.3.0/frontend/src/extensions.js +365 -0
- django_templates_pro-0.3.0/frontend/src/icons.js +34 -0
- django_templates_pro-0.3.0/frontend/src/index.js +48 -0
- django_templates_pro-0.3.0/frontend/vite.config.js +20 -0
- django_templates_pro-0.3.0/noxfile.py +26 -0
- django_templates_pro-0.3.0/pyproject.toml +111 -0
- django_templates_pro-0.3.0/requirements-dev.txt +9 -0
- django_templates_pro-0.3.0/requirements.txt +22 -0
- django_templates_pro-0.3.0/src/templates_pro/__init__.py +24 -0
- django_templates_pro-0.3.0/src/templates_pro/admin.py +142 -0
- django_templates_pro-0.3.0/src/templates_pro/apps.py +19 -0
- django_templates_pro-0.3.0/src/templates_pro/checks.py +49 -0
- django_templates_pro-0.3.0/src/templates_pro/conf.py +82 -0
- django_templates_pro-0.3.0/src/templates_pro/core/__init__.py +0 -0
- django_templates_pro-0.3.0/src/templates_pro/core/compiler.py +633 -0
- django_templates_pro-0.3.0/src/templates_pro/core/engine.py +252 -0
- django_templates_pro-0.3.0/src/templates_pro/core/formatting.py +289 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/__init__.py +149 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/docx.py +625 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/html.py +13 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/pdf.py +65 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/txt.py +43 -0
- django_templates_pro-0.3.0/src/templates_pro/core/renderers/typst_pdf.py +590 -0
- django_templates_pro-0.3.0/src/templates_pro/core/schema.py +272 -0
- django_templates_pro-0.3.0/src/templates_pro/demo/__init__.py +69 -0
- django_templates_pro-0.3.0/src/templates_pro/demo/__main__.py +7 -0
- django_templates_pro-0.3.0/src/templates_pro/engines.py +40 -0
- django_templates_pro-0.3.0/src/templates_pro/fetchers.py +124 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSans-Bold.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSans-BoldItalic.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSans-Italic.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSans-Regular.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSansHebrew-Bold.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/NotoSansHebrew-Regular.ttf +0 -0
- django_templates_pro-0.3.0/src/templates_pro/fonts/OFL.txt +93 -0
- django_templates_pro-0.3.0/src/templates_pro/forms.py +58 -0
- django_templates_pro-0.3.0/src/templates_pro/management/__init__.py +0 -0
- django_templates_pro-0.3.0/src/templates_pro/management/commands/__init__.py +0 -0
- django_templates_pro-0.3.0/src/templates_pro/management/commands/templates_pro_samples.py +49 -0
- django_templates_pro-0.3.0/src/templates_pro/management/commands/templates_pro_validate.py +40 -0
- django_templates_pro-0.3.0/src/templates_pro/migrations/0001_initial.py +406 -0
- django_templates_pro-0.3.0/src/templates_pro/migrations/0002_document_direction.py +28 -0
- django_templates_pro-0.3.0/src/templates_pro/migrations/__init__.py +0 -0
- django_templates_pro-0.3.0/src/templates_pro/models.py +399 -0
- django_templates_pro-0.3.0/src/templates_pro/registry.py +124 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/__init__.py +13 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/apps.py +16 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-bank-details.html +1 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-company-letterhead.html +2 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-customer-details.html +2 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-page-footer-he.html +1 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-page-footer.html +1 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-payment-terms.html +3 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/blocks/sample-signature.html +2 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/manifest.json +126 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-employment-certificate.html +10 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-invoice-hebrew.html +16 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-invoice-modern.html +6 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-invoice-standard.html +13 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-order-confirmation.html +8 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/content/templates/sample-welcome-letter.html +11 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/doctemplate_types.py +140 -0
- django_templates_pro-0.3.0/src/templates_pro/samples/loader.py +134 -0
- django_templates_pro-0.3.0/src/templates_pro/services.py +350 -0
- django_templates_pro-0.3.0/src/templates_pro/signals.py +17 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/editor/templates-pro-editor.css +1 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/editor/templates-pro-editor.js +163 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/themes/classic.css +20 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/themes/corporate.css +20 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/themes/minimal.css +11 -0
- django_templates_pro-0.3.0/src/templates_pro/static/templates_pro/themes/modern.css +21 -0
- django_templates_pro-0.3.0/src/templates_pro/templates/templates_pro/widgets/editor.html +6 -0
- django_templates_pro-0.3.0/src/templates_pro/themes.py +73 -0
- django_templates_pro-0.3.0/src/templates_pro/urls.py +10 -0
- django_templates_pro-0.3.0/src/templates_pro/views.py +93 -0
- django_templates_pro-0.3.0/src/templates_pro/widgets.py +126 -0
- django_templates_pro-0.3.0/tests/__init__.py +0 -0
- django_templates_pro-0.3.0/tests/conftest.py +29 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--bank-details.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--company-letterhead.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--customer-details.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--page-footer-he.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--page-footer.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--payment-terms.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/blocks--signature.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--employment-certificate.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--invoice-hebrew.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--invoice-modern.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--invoice-standard.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--order-confirmation.html +1 -0
- django_templates_pro-0.3.0/tests/fixtures/editor_roundtrip/templates--welcome-letter.html +1 -0
- django_templates_pro-0.3.0/tests/settings.py +38 -0
- django_templates_pro-0.3.0/tests/test_compiler.py +146 -0
- django_templates_pro-0.3.0/tests/test_contract.py +41 -0
- django_templates_pro-0.3.0/tests/test_demo_docs.py +126 -0
- django_templates_pro-0.3.0/tests/test_demo_launcher.py +39 -0
- django_templates_pro-0.3.0/tests/test_django.py +189 -0
- django_templates_pro-0.3.0/tests/test_engine.py +82 -0
- django_templates_pro-0.3.0/tests/test_formatting.py +53 -0
- django_templates_pro-0.3.0/tests/test_samples.py +104 -0
- django_templates_pro-0.3.0/tests/test_typst_rtl.py +195 -0
- django_templates_pro-0.3.0/tests/test_views_admin.py +76 -0
- django_templates_pro-0.3.0/tests/testapp/__init__.py +0 -0
- django_templates_pro-0.3.0/tests/testapp/doctemplate_types.py +35 -0
- django_templates_pro-0.3.0/tests/urls.py +7 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.eggs/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.nox/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
frontend/node_modules/
|
|
13
|
+
example/db.sqlite3
|
|
14
|
+
example/media/
|
|
15
|
+
example/staticfiles/
|
|
16
|
+
.DS_Store
|
|
17
|
+
# NOTE: src/templates_pro/static/templates_pro/editor/ (built bundle) IS committed.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 — 2026-11-12
|
|
4
|
+
|
|
5
|
+
**The demo website ships with pip.**
|
|
6
|
+
|
|
7
|
+
- Tested on Python 3.14 and Django 6.0 / 6.1 (classifiers, nox and CI matrices). Python 3.14
|
|
8
|
+
needs Django 5.2.8+: Django 4.2 and 5.1 do not run on it.
|
|
9
|
+
|
|
10
|
+
- Docs: new pages for the admin, the samples and demo, the management commands and
|
|
11
|
+
troubleshooting; "how formatting works" in `docs/formatting.md`; where document data comes
|
|
12
|
+
from in `docs/concepts.md`. `docs/index.md` lists every page in reading order.
|
|
13
|
+
- Demo: a documentation page at `/docs/` renders the repository's Markdown files.
|
|
14
|
+
- Demo: `python example/run_demo.py` sets up and starts the demo in one command (virtual
|
|
15
|
+
environment, install, migrate, seed on first run, runserver), from any folder.
|
|
16
|
+
- Demo in the pip package: `python -m templates_pro.demo` (console script `templates-pro-demo`)
|
|
17
|
+
copies the demo project and its documentation into a folder of its own and runs it. The
|
|
18
|
+
wheel ships `example/` and the docs under `templates_pro/demo/project/`.
|
|
19
|
+
- Project URLs on PyPI point at github.com/latingate/django-templates-pro, and README links
|
|
20
|
+
are absolute so they work on the PyPI page (the demo's `/docs/` still opens them in place).
|
|
21
|
+
- Removed `docs/SETUP.md`, an outdated copy of `SETUP.md`.
|
|
22
|
+
|
|
23
|
+
## 0.2.0 — 2026-11-10
|
|
24
|
+
|
|
25
|
+
**Pure-pip install and right-to-left support.**
|
|
26
|
+
|
|
27
|
+
- **PDF via Typst by default.** The `typst` wheel bundles the compiler, so PDF output needs no
|
|
28
|
+
system libraries on any OS. The editor's HTML is converted to Typst (tables with header rows
|
|
29
|
+
and merged cells, lists, quotes, colours, images, header/footer blocks, page X of Y). Document
|
|
30
|
+
text only ever becomes Typst string literals.
|
|
31
|
+
- **WeasyPrint is now optional:** `pip install "django-templates-pro[weasyprint]"` and
|
|
32
|
+
`TEMPLATES_PRO["PDF_ENGINE"] = "weasyprint"`.
|
|
33
|
+
- **Bundled fonts:** Noto Sans and Noto Sans Hebrew (SIL OFL 1.1). New settings
|
|
34
|
+
`TYPST_FONT_PATHS` and `TYPST_IGNORE_SYSTEM_FONTS`.
|
|
35
|
+
- **Themes have a Typst style** next to their CSS; project themes add one with
|
|
36
|
+
`THEMES[key]["typst"]` (`docs/rendering.md#themes`).
|
|
37
|
+
- **Text direction per template** (`DocumentTemplate.direction`: auto / ltr / rtl, migration
|
|
38
|
+
`0002`). *Auto* is RTL for Hebrew, Arabic, Persian, Urdu… locales. It applies in the editor
|
|
39
|
+
(live), HTML (`dir`), PDF, DOCX (bidi paragraphs, tables, section, complex-script runs) and
|
|
40
|
+
previews. Each paragraph follows its first letter's direction.
|
|
41
|
+
- Widget options `direction`, `direction_field`, `locale_field`.
|
|
42
|
+
- HTML themes use `text-align: start` and have RTL rules.
|
|
43
|
+
- `typst` and `python-docx` are regular dependencies. The `[pdf]`, `[docx]` and `[all]` extras
|
|
44
|
+
are kept but empty.
|
|
45
|
+
- **Starter content for pip installs:** the optional app `templates_pro.samples` registers four
|
|
46
|
+
sample template types (`sample_invoice`, `sample_letter`, `sample_order`, `sample_certificate`),
|
|
47
|
+
and `manage.py templates_pro_samples` loads six templates, seven blocks and ten constants
|
|
48
|
+
(`--overwrite` resets them, `--remove` deletes them). Everything has a `sample-` slug; existing
|
|
49
|
+
constants are never changed (`docs/quickstart.md`).
|
|
50
|
+
- Demo: Hebrew RTL invoice, Hebrew page footer, an Israeli customer (he_IL, ILS), and a Typst
|
|
51
|
+
style for the project theme.
|
|
52
|
+
- Fixed: the demo read sample files with the system code page on Windows (now UTF-8).
|
|
53
|
+
|
|
54
|
+
## 0.1.0 — 2026-11-10
|
|
55
|
+
|
|
56
|
+
First release.
|
|
57
|
+
|
|
58
|
+
- Template types with schemas (`Var`, `Group`, `ListOf`), autodiscovered from `doctemplate_types.py`.
|
|
59
|
+
- TipTap 3 editor widget: variables, constants, dynamic values, shared blocks, repeat sections,
|
|
60
|
+
repeated table rows, conditions, per-chip formatting, `{{` picker, live preview.
|
|
61
|
+
Presets `full` / `simple` / `minimal`; skins `default` / `dark` / `paper` / `compact`; custom toolbars.
|
|
62
|
+
- Compiler from editor HTML to sandboxed Jinja2 with an allowlist sanitiser.
|
|
63
|
+
- Babel formatting for dates, times, numbers, money, percent, text and booleans; locale and currency
|
|
64
|
+
hooks per object.
|
|
65
|
+
- Renderers: HTML, PDF (WeasyPrint, running header/footer, page numbers), DOCX (python-docx), TXT.
|
|
66
|
+
- Themes: classic, modern, minimal, corporate, none; project themes via settings.
|
|
67
|
+
- Admin for templates, blocks ("used by"), constants and generated documents.
|
|
68
|
+
- `services.render / render_to_response / generate / preview_document`.
|
|
69
|
+
- Safe URL fetcher for PDF/DOCX images; system checks; `templates_pro_validate` command.
|
|
70
|
+
- Demo project with five templates, six blocks and sample data.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Peltransport
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: django-templates-pro
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: WYSIWYG document templates for Django: variables, constants, dynamic values, formatting and shared blocks, rendered to HTML, PDF, DOCX and TXT, with right-to-left (Hebrew, Arabic) support. Pure pip: no system libraries.
|
|
5
|
+
Project-URL: Documentation, https://github.com/latingate/django-templates-pro/tree/master/docs
|
|
6
|
+
Project-URL: Source, https://github.com/latingate/django-templates-pro
|
|
7
|
+
Project-URL: Changelog, https://github.com/latingate/django-templates-pro/blob/master/CHANGELOG.md
|
|
8
|
+
Author: Peltransport
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: django,docx,hebrew,jinja2,mail-merge,pdf,rtl,templates,tiptap,typst,wysiwyg
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Web Environment
|
|
14
|
+
Classifier: Framework :: Django
|
|
15
|
+
Classifier: Framework :: Django :: 4.2
|
|
16
|
+
Classifier: Framework :: Django :: 5.0
|
|
17
|
+
Classifier: Framework :: Django :: 5.1
|
|
18
|
+
Classifier: Framework :: Django :: 5.2
|
|
19
|
+
Classifier: Framework :: Django :: 6.0
|
|
20
|
+
Classifier: Framework :: Django :: 6.1
|
|
21
|
+
Classifier: Intended Audience :: Developers
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
29
|
+
Classifier: Topic :: Office/Business
|
|
30
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
31
|
+
Requires-Python: >=3.10
|
|
32
|
+
Requires-Dist: babel>=2.12
|
|
33
|
+
Requires-Dist: django>=4.2
|
|
34
|
+
Requires-Dist: html2text>=2024.2.26
|
|
35
|
+
Requires-Dist: jinja2>=3.1
|
|
36
|
+
Requires-Dist: python-docx>=1.1
|
|
37
|
+
Requires-Dist: typst>=0.13
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: nox>=2024.3; extra == 'dev'
|
|
41
|
+
Requires-Dist: pypdf>=4; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest-django>=4.8; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
44
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
45
|
+
Provides-Extra: docx
|
|
46
|
+
Provides-Extra: pdf
|
|
47
|
+
Provides-Extra: weasyprint
|
|
48
|
+
Requires-Dist: weasyprint>=60; extra == 'weasyprint'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+
# django-templates-pro
|
|
52
|
+
|
|
53
|
+
WYSIWYG document templates for Django. Admins and users write templates in a
|
|
54
|
+
rich-text editor (TipTap). The templates can contain:
|
|
55
|
+
|
|
56
|
+
- **variables** (invoice number, customer name…), declared per *template type* in code
|
|
57
|
+
- **constants** (website name, company address…), edited in the admin
|
|
58
|
+
- **dynamic values** (today, current time, year, row number, page X of Y)
|
|
59
|
+
- **formatting** for dates, times, numbers, money, percentages and text, chosen per chip
|
|
60
|
+
- **shared blocks** (header, footer, customer details…), edited once and used everywhere
|
|
61
|
+
- **repeat sections / repeated table rows** (invoice lines) and **conditions**
|
|
62
|
+
- **text direction** per template (auto from the locale, LTR or RTL), in the editor and every output
|
|
63
|
+
|
|
64
|
+
Templates render to **HTML, PDF (Typst), DOCX (python-docx) and TXT**, with
|
|
65
|
+
full **right-to-left** support (Hebrew, Arabic…). Everything installs with
|
|
66
|
+
pip alone: no system libraries, on Windows, macOS and Linux.
|
|
67
|
+
|
|
68
|
+
Users never write template syntax. The editor stores HTML with chips, and the
|
|
69
|
+
package compiles it to **sandboxed Jinja2**. Contexts must be plain data, so
|
|
70
|
+
templates can't reach your models, the ORM or Python internals.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from templates_pro.services import render_to_response
|
|
74
|
+
|
|
75
|
+
def invoice_pdf(request, pk):
|
|
76
|
+
invoice = get_object_or_404(Invoice, pk=pk)
|
|
77
|
+
return render_to_response("invoice", invoice, fmt="pdf") # the type's default template
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install django-templates-pro # HTML, PDF, DOCX and TXT; nothing else to install
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
INSTALLED_APPS = [..., "django.contrib.contenttypes", "django.contrib.staticfiles", "templates_pro"]
|
|
88
|
+
# urls.py — preview endpoints used by the editor
|
|
89
|
+
path("templates-pro/", include("templates_pro.urls")),
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python manage.py migrate
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Want something to look at first? Add `"templates_pro.samples"` to `INSTALLED_APPS` and run
|
|
97
|
+
`python manage.py templates_pro_samples`: six ready-made templates (one Hebrew, right-to-left),
|
|
98
|
+
seven shared blocks and constants appear in the admin, with working previews
|
|
99
|
+
([sample content](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md#start-from-the-samples-optional)).
|
|
100
|
+
|
|
101
|
+
Then declare what can be templated, in any app's `doctemplate_types.py`:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from templates_pro import register, TemplateType, Var, Group, ListOf
|
|
105
|
+
|
|
106
|
+
@register
|
|
107
|
+
class InvoiceTemplate(TemplateType):
|
|
108
|
+
key = "invoice"
|
|
109
|
+
label = "Invoice"
|
|
110
|
+
filename = "invoice-{invoice.number}"
|
|
111
|
+
schema = {
|
|
112
|
+
"invoice": Group("Invoice", {
|
|
113
|
+
"number": Var("string", "Invoice number", sample="INV-0042"),
|
|
114
|
+
"date": Var("date", "Date"),
|
|
115
|
+
"total": Var("money", "Total"),
|
|
116
|
+
"lines": ListOf("Line items", {
|
|
117
|
+
"description": Var("string", "Description"),
|
|
118
|
+
"amount": Var("money", "Amount"),
|
|
119
|
+
}),
|
|
120
|
+
}),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
def build_context(self, invoice, **kwargs):
|
|
124
|
+
return {"invoice": {
|
|
125
|
+
"number": invoice.number, "date": invoice.date, "total": invoice.total,
|
|
126
|
+
"lines": [{"description": l.description, "amount": l.amount} for l in invoice.lines.all()],
|
|
127
|
+
}}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Open **Admin → Document templates**, pick the type, and write.
|
|
131
|
+
|
|
132
|
+
Requirements: Python 3.10+ and Django 4.2+ (on Python 3.14: Django 5.2.8+). That's all: PDF output uses the
|
|
133
|
+
`typst` wheel and bundled fonts (Latin + Hebrew). WeasyPrint is available as an
|
|
134
|
+
optional PDF engine ([rendering.md](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md#pdf-engines)).
|
|
135
|
+
|
|
136
|
+
## Try the demo
|
|
137
|
+
|
|
138
|
+
After `pip install django-templates-pro`:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
python -m templates_pro.demo # http://127.0.0.1:8000 (admin / admin)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
It copies the demo project into `./templates-pro-demo` (another folder: `--dir`),
|
|
145
|
+
migrates its own SQLite database, loads the demo content and starts the server. It
|
|
146
|
+
never touches your own project. Run the same command again to restart it.
|
|
147
|
+
|
|
148
|
+
From a clone of the repository, `python example/run_demo.py` does the same in place,
|
|
149
|
+
and also creates `.venv` and installs the package when needed. Details are in
|
|
150
|
+
[docs/samples.md](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md#run-it).
|
|
151
|
+
|
|
152
|
+
The demo has six templates (an English and a Hebrew right-to-left invoice, a
|
|
153
|
+
modern invoice, a letter, an order email and an HR certificate), seven shared
|
|
154
|
+
blocks (one of them nested), constants, document themes (one of them a
|
|
155
|
+
project theme), every editor preset and skin, and a user-facing editor page.
|
|
156
|
+
It also serves this documentation at <http://127.0.0.1:8000/docs/>.
|
|
157
|
+
|
|
158
|
+
## Documentation
|
|
159
|
+
|
|
160
|
+
The full list, in reading order, is in [docs/index.md](https://github.com/latingate/django-templates-pro/blob/master/docs/index.md).
|
|
161
|
+
|
|
162
|
+
| | |
|
|
163
|
+
|---|---|
|
|
164
|
+
| [**Setup guide**](https://github.com/latingate/django-templates-pro/blob/master/SETUP.md) | step-by-step local setup, demo, PyCharm, Windows PDF, troubleshooting |
|
|
165
|
+
| [Installation](https://github.com/latingate/django-templates-pro/blob/master/docs/installation.md) | requirements, settings, URLs, system libraries |
|
|
166
|
+
| [Quickstart](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md) | first template type, first template, first PDF |
|
|
167
|
+
| [Samples, demo and examples](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md) | the packaged samples, the demo project and the sample HTML files, and how to use them |
|
|
168
|
+
| [Concepts](https://github.com/latingate/django-templates-pro/blob/master/docs/concepts.md) | variables, constants, dynamic values, blocks, repeats, conditions |
|
|
169
|
+
| [Template types](https://github.com/latingate/django-templates-pro/blob/master/docs/template-types.md) | schemas, `build_context`, samples, locale & currency hooks |
|
|
170
|
+
| [Formatting](https://github.com/latingate/django-templates-pro/blob/master/docs/formatting.md) | how formatting works; date/number/money/text format reference |
|
|
171
|
+
| [The editor](https://github.com/latingate/django-templates-pro/blob/master/docs/editor.md) | widget options, presets, skins, toolbar, JS API, styling |
|
|
172
|
+
| [The admin](https://github.com/latingate/django-templates-pro/blob/master/docs/admin.md) | templates, blocks, constants, generated documents, previews, permissions |
|
|
173
|
+
| [Rendering](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md) | services API, formats, themes, page setup, stored documents, custom renderers |
|
|
174
|
+
| [Security](https://github.com/latingate/django-templates-pro/blob/master/docs/security.md) | the sandbox, sanitising, URL fetching, permissions |
|
|
175
|
+
| [Settings](https://github.com/latingate/django-templates-pro/blob/master/docs/settings.md) | `TEMPLATES_PRO` reference |
|
|
176
|
+
| [Management commands](https://github.com/latingate/django-templates-pro/blob/master/docs/commands.md) | `templates_pro_validate`, `templates_pro_samples`, `seed_demo` |
|
|
177
|
+
| [Operations](https://github.com/latingate/django-templates-pro/blob/master/docs/operations.md) | schema changes, caching, migrations, upgrades |
|
|
178
|
+
| [Troubleshooting](https://github.com/latingate/django-templates-pro/blob/master/docs/troubleshooting.md) | symptoms, causes and fixes |
|
|
179
|
+
| [HTML contract](https://github.com/latingate/django-templates-pro/blob/master/docs/html-contract.md) | the chip markup shared by editor and compiler |
|
|
180
|
+
| [Development](https://github.com/latingate/django-templates-pro/blob/master/docs/development.md) | repo layout, tests, building the editor bundle |
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# django-templates-pro
|
|
2
|
+
|
|
3
|
+
WYSIWYG document templates for Django. Admins and users write templates in a
|
|
4
|
+
rich-text editor (TipTap). The templates can contain:
|
|
5
|
+
|
|
6
|
+
- **variables** (invoice number, customer name…), declared per *template type* in code
|
|
7
|
+
- **constants** (website name, company address…), edited in the admin
|
|
8
|
+
- **dynamic values** (today, current time, year, row number, page X of Y)
|
|
9
|
+
- **formatting** for dates, times, numbers, money, percentages and text, chosen per chip
|
|
10
|
+
- **shared blocks** (header, footer, customer details…), edited once and used everywhere
|
|
11
|
+
- **repeat sections / repeated table rows** (invoice lines) and **conditions**
|
|
12
|
+
- **text direction** per template (auto from the locale, LTR or RTL), in the editor and every output
|
|
13
|
+
|
|
14
|
+
Templates render to **HTML, PDF (Typst), DOCX (python-docx) and TXT**, with
|
|
15
|
+
full **right-to-left** support (Hebrew, Arabic…). Everything installs with
|
|
16
|
+
pip alone: no system libraries, on Windows, macOS and Linux.
|
|
17
|
+
|
|
18
|
+
Users never write template syntax. The editor stores HTML with chips, and the
|
|
19
|
+
package compiles it to **sandboxed Jinja2**. Contexts must be plain data, so
|
|
20
|
+
templates can't reach your models, the ORM or Python internals.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from templates_pro.services import render_to_response
|
|
24
|
+
|
|
25
|
+
def invoice_pdf(request, pk):
|
|
26
|
+
invoice = get_object_or_404(Invoice, pk=pk)
|
|
27
|
+
return render_to_response("invoice", invoice, fmt="pdf") # the type's default template
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install django-templates-pro # HTML, PDF, DOCX and TXT; nothing else to install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
INSTALLED_APPS = [..., "django.contrib.contenttypes", "django.contrib.staticfiles", "templates_pro"]
|
|
38
|
+
# urls.py — preview endpoints used by the editor
|
|
39
|
+
path("templates-pro/", include("templates_pro.urls")),
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python manage.py migrate
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Want something to look at first? Add `"templates_pro.samples"` to `INSTALLED_APPS` and run
|
|
47
|
+
`python manage.py templates_pro_samples`: six ready-made templates (one Hebrew, right-to-left),
|
|
48
|
+
seven shared blocks and constants appear in the admin, with working previews
|
|
49
|
+
([sample content](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md#start-from-the-samples-optional)).
|
|
50
|
+
|
|
51
|
+
Then declare what can be templated, in any app's `doctemplate_types.py`:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from templates_pro import register, TemplateType, Var, Group, ListOf
|
|
55
|
+
|
|
56
|
+
@register
|
|
57
|
+
class InvoiceTemplate(TemplateType):
|
|
58
|
+
key = "invoice"
|
|
59
|
+
label = "Invoice"
|
|
60
|
+
filename = "invoice-{invoice.number}"
|
|
61
|
+
schema = {
|
|
62
|
+
"invoice": Group("Invoice", {
|
|
63
|
+
"number": Var("string", "Invoice number", sample="INV-0042"),
|
|
64
|
+
"date": Var("date", "Date"),
|
|
65
|
+
"total": Var("money", "Total"),
|
|
66
|
+
"lines": ListOf("Line items", {
|
|
67
|
+
"description": Var("string", "Description"),
|
|
68
|
+
"amount": Var("money", "Amount"),
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
def build_context(self, invoice, **kwargs):
|
|
74
|
+
return {"invoice": {
|
|
75
|
+
"number": invoice.number, "date": invoice.date, "total": invoice.total,
|
|
76
|
+
"lines": [{"description": l.description, "amount": l.amount} for l in invoice.lines.all()],
|
|
77
|
+
}}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Open **Admin → Document templates**, pick the type, and write.
|
|
81
|
+
|
|
82
|
+
Requirements: Python 3.10+ and Django 4.2+ (on Python 3.14: Django 5.2.8+). That's all: PDF output uses the
|
|
83
|
+
`typst` wheel and bundled fonts (Latin + Hebrew). WeasyPrint is available as an
|
|
84
|
+
optional PDF engine ([rendering.md](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md#pdf-engines)).
|
|
85
|
+
|
|
86
|
+
## Try the demo
|
|
87
|
+
|
|
88
|
+
After `pip install django-templates-pro`:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python -m templates_pro.demo # http://127.0.0.1:8000 (admin / admin)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
It copies the demo project into `./templates-pro-demo` (another folder: `--dir`),
|
|
95
|
+
migrates its own SQLite database, loads the demo content and starts the server. It
|
|
96
|
+
never touches your own project. Run the same command again to restart it.
|
|
97
|
+
|
|
98
|
+
From a clone of the repository, `python example/run_demo.py` does the same in place,
|
|
99
|
+
and also creates `.venv` and installs the package when needed. Details are in
|
|
100
|
+
[docs/samples.md](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md#run-it).
|
|
101
|
+
|
|
102
|
+
The demo has six templates (an English and a Hebrew right-to-left invoice, a
|
|
103
|
+
modern invoice, a letter, an order email and an HR certificate), seven shared
|
|
104
|
+
blocks (one of them nested), constants, document themes (one of them a
|
|
105
|
+
project theme), every editor preset and skin, and a user-facing editor page.
|
|
106
|
+
It also serves this documentation at <http://127.0.0.1:8000/docs/>.
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
The full list, in reading order, is in [docs/index.md](https://github.com/latingate/django-templates-pro/blob/master/docs/index.md).
|
|
111
|
+
|
|
112
|
+
| | |
|
|
113
|
+
|---|---|
|
|
114
|
+
| [**Setup guide**](https://github.com/latingate/django-templates-pro/blob/master/SETUP.md) | step-by-step local setup, demo, PyCharm, Windows PDF, troubleshooting |
|
|
115
|
+
| [Installation](https://github.com/latingate/django-templates-pro/blob/master/docs/installation.md) | requirements, settings, URLs, system libraries |
|
|
116
|
+
| [Quickstart](https://github.com/latingate/django-templates-pro/blob/master/docs/quickstart.md) | first template type, first template, first PDF |
|
|
117
|
+
| [Samples, demo and examples](https://github.com/latingate/django-templates-pro/blob/master/docs/samples.md) | the packaged samples, the demo project and the sample HTML files, and how to use them |
|
|
118
|
+
| [Concepts](https://github.com/latingate/django-templates-pro/blob/master/docs/concepts.md) | variables, constants, dynamic values, blocks, repeats, conditions |
|
|
119
|
+
| [Template types](https://github.com/latingate/django-templates-pro/blob/master/docs/template-types.md) | schemas, `build_context`, samples, locale & currency hooks |
|
|
120
|
+
| [Formatting](https://github.com/latingate/django-templates-pro/blob/master/docs/formatting.md) | how formatting works; date/number/money/text format reference |
|
|
121
|
+
| [The editor](https://github.com/latingate/django-templates-pro/blob/master/docs/editor.md) | widget options, presets, skins, toolbar, JS API, styling |
|
|
122
|
+
| [The admin](https://github.com/latingate/django-templates-pro/blob/master/docs/admin.md) | templates, blocks, constants, generated documents, previews, permissions |
|
|
123
|
+
| [Rendering](https://github.com/latingate/django-templates-pro/blob/master/docs/rendering.md) | services API, formats, themes, page setup, stored documents, custom renderers |
|
|
124
|
+
| [Security](https://github.com/latingate/django-templates-pro/blob/master/docs/security.md) | the sandbox, sanitising, URL fetching, permissions |
|
|
125
|
+
| [Settings](https://github.com/latingate/django-templates-pro/blob/master/docs/settings.md) | `TEMPLATES_PRO` reference |
|
|
126
|
+
| [Management commands](https://github.com/latingate/django-templates-pro/blob/master/docs/commands.md) | `templates_pro_validate`, `templates_pro_samples`, `seed_demo` |
|
|
127
|
+
| [Operations](https://github.com/latingate/django-templates-pro/blob/master/docs/operations.md) | schema changes, caching, migrations, upgrades |
|
|
128
|
+
| [Troubleshooting](https://github.com/latingate/django-templates-pro/blob/master/docs/troubleshooting.md) | symptoms, causes and fixes |
|
|
129
|
+
| [HTML contract](https://github.com/latingate/django-templates-pro/blob/master/docs/html-contract.md) | the chip markup shared by editor and compiler |
|
|
130
|
+
| [Development](https://github.com/latingate/django-templates-pro/blob/master/docs/development.md) | repo layout, tests, building the editor bundle |
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|