Repository navigation
truncatechars_html, truncatewords_html, filesizeformat and humanize's intword now render fast. Before this release they ran only 1.2–1.5x faster than stock Django. On the benchmark, {{ html|truncatechars_html:20 }} is now 15x faster than stock, truncatewords_html 13x, {{ n|intword }} 15x and {{ n|filesizeformat }} 10x.
pip install -U django-rust-templatesFaster
truncatechars_html/truncatewords_html: Django runs Python'sHTMLParserover every value. The native version reproduces the parser's behaviour, quirks included, for ordinary HTML: plain tags with attributes, and common entity references such as&, and'.filesizeformatandintword(django.contrib.humanize): integer inputs are formatted natively. Their translated unit strings are looked up once per active translation instead of on every call.
Output stays byte-identical to stock Django, on every supported Python version. Comments, <script>/<style> content, a bare < or &, unusual entities, non-integer numbers and patched module globals still run the Python code.