I am using django templating, and for readability I have html that looks similar to the following:
{% if some_variable %}
text
{% else %}
nothing exi
"I think a front-end development tool, such as grunt-contrib-htmlmin, should be used to minify Django template files before deploying them to production server."
I had a need to do this some time ago to increase performance and decrease latency. I wrote a template minimizer that will minimize the HTML, CSS, and Javascript in your templates beforehand so that the pages are composed minimized. It integrates into Django as a Django command, understands the intricacies of the Django tempting language, and is extendable. You can find it on pypi at the link below:
django-template-minimizer