A Django template engine powered by Typst
Project description
Django Typst
A Django template engine that uses Typst to render Portable Document Format (PDF) files.
Full documentation can be found at https://django-typst-engine.readthedocs.io/en/latest/
Installation and Configuration
The Django Typst engine is available from PyPI so you can install it with all the usual tools:
pip install django_typst
# or
uv add django_typst
# or
poetry add django_typst
Once installed, to make the typst engine available, you need to add it to the
TEMPLATES configuration in your settings.py. e.g.:
TEMPLATES = [
...
{
"BACKEND": "django_typst.TypstEngine",
"NAME": "typst",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": False,
"OPTIONS": {
"ROOT": None,
"FONT_PATHS": [],
"IGNORE_SYSTEM_FONTS": False,
"PDF_STANDARD": "1.7",
"PPI": None,
}
},
]
Note that this should be in addition to the standard Django template engine that was already there.
All the OPTIONS are... optional and the values above represent their defaults should
no alternative be provided.
| Option | Description | Default |
|---|---|---|
| ROOT | The root path to use for relative paths | None* |
| FONT_PATHS | Paths to look in for fonts | [] |
| IGNORE_SYSTEM_FONTS | Only consider fonts in the defined font paths | False |
| PDF_STANDARD | PDF revision to target (1.7, a2-b, a3-b) |
"1.7" |
| PPI | Pixel Per Inch for included PNG | None |
* The engine with use the folder the template is in as the root if one is not specified.
[!NOTE] The Django Typst Engine does support loading templates from app dirs with the
APP_DIRconfiguration, but just like the jinja2 engine, it expects the in-app folder to have an engine specific name oftypst. So if you want to have templates in app directories, please ensure they sit within a folder calledtypst.
Usage
To use this engine with one of the standard Django class based views you only need to
set the template_engine class property to the value "typst". You should also set the
content_type property to the value "application/pdf" to ensure the PDF is returned
with the correct content type. For example, in a simple TemplateView it would look
like this:
from django.views import generic
class MyTemplateView(generic.TemplateView):
template_engine = "typst"
content_type = "application/pdf"
...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_typst-0.1.4.tar.gz.
File metadata
- Download URL: django_typst-0.1.4.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78f19df331ad95dece39d1407d9db8e620473be8ab306537083aa60b8cec754a
|
|
| MD5 |
a1f16c3d33b3878207439dde1c4afd6a
|
|
| BLAKE2b-256 |
0d189d1f7b2eb8629873197ecb04feb912bb7b39ddbf511c47758daec4a963a4
|
Provenance
The following attestation bundles were made for django_typst-0.1.4.tar.gz:
Publisher:
publish.yml on a-musing-moose/django-typst-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_typst-0.1.4.tar.gz -
Subject digest:
78f19df331ad95dece39d1407d9db8e620473be8ab306537083aa60b8cec754a - Sigstore transparency entry: 674266425
- Sigstore integration time:
-
Permalink:
a-musing-moose/django-typst-engine@fbaa43aeef2b596b8f8fc65ed1a7a530ffad82f7 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/a-musing-moose
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fbaa43aeef2b596b8f8fc65ed1a7a530ffad82f7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_typst-0.1.4-py3-none-any.whl.
File metadata
- Download URL: django_typst-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21d672230a23e58c2303b830fa149125547b2b2d4d9e01a83011d61774da6a44
|
|
| MD5 |
05747370b97197747a9ee3b5b8d9f6eb
|
|
| BLAKE2b-256 |
f923a9547dfc546304a77768b565e04a8e8b20e66db5c855598b1bae7cf8f306
|
Provenance
The following attestation bundles were made for django_typst-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on a-musing-moose/django-typst-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_typst-0.1.4-py3-none-any.whl -
Subject digest:
21d672230a23e58c2303b830fa149125547b2b2d4d9e01a83011d61774da6a44 - Sigstore transparency entry: 674266500
- Sigstore integration time:
-
Permalink:
a-musing-moose/django-typst-engine@fbaa43aeef2b596b8f8fc65ed1a7a530ffad82f7 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/a-musing-moose
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fbaa43aeef2b596b8f8fc65ed1a7a530ffad82f7 -
Trigger Event:
release
-
Statement type: