Django Rusty Templates is an experimental reimplementation of Django's templating language in Rust.
- 100% compatibility of rendered output.
- Error reporting that is at least as useful as Django's errors.
- Improved performance over Django's pure Python implementation.
Django Rusty Templates is not yet ready for full release, so it is not available on PyPI yet. Instead it can be installed from github or from a local clone:
$ pip install git+https://github.com/LilyFoote/django-rusty-templates.git
$ git clone [email protected]:LilyFoote/django-rusty-templates.git
$ pip install ./django-rusty-templates
You will need a rust compiler installed (https://rustup.rs/).
Add an entry to your TEMPLATES
setting with "BACKEND"
set to "django_rusty_templates.RustyTemplates"
:
TEMPLATES = [
{
"BACKEND": "django_rusty_templates.RustyTemplates",
... # Other configuration options
},
]
Django Rusty Templates is open to contributions. These can come in many forms:
- Implementing missing features, such as filters and tags built into Django.
- Reporting bugs where Django Rusty Templates gives the wrong result.
- Adding new test cases to ensure Django Rusty Templates behaves the same as Django.
- Adding benchmarks to track performance.
- Refactoring for readability or performance.
To develop locally, first create a virtualenv using your preferred method.
$ python -m venv .venv
Activate the virtualenv and install the requirements:
$ source .venv/bin/activate
$ pip install -r requirements.txt
To run the Python tests, build Django Rusty Templates in develop mode with maturin and then run pytest. Each change in rust needs a new execution of maturin develop.
$ maturin develop
$ pytest
You can also run the Rust tests:
$ cargo test
If you get an ImportError
from python, you may need to set the PYTHONPATH
environment variable:
export PYTHONPATH=/path/to/venv/lib/python3.x/site-packages
When submitting a PR we check coverage. You can check coverage locally with
$ cargo llvm-cov
# generate html
$ cargo llvm-cov --html
# open it
$ open -a <your_browser> target/llvm-cov/html/index.html
Note this only checks the coverage generated by the Rust tests. We also measure coverage generated by the Python tests in CI, which means missing coverage locally isn't always an issue.