64
You can use the spaceless
template tag. It:
Removes whitespace between HTML tags.
{% spaceless %}
<p>
<a href="foo/">Foo</a>
</p>
{% endspaceless %}
4
-
Look toward middelware, eg “htmlmin”. It processes the file at a time. In addition it has a decorator.
https://crate.io/packages/django-htmlmin -
gzip will give the same effect. Probably would have cost to opt out of trimming.
Look towards django middelware or nginx gzip.- django.middleware.gzip.GZipMiddleware
- http://wiki.nginx.org/HttpGzipModule
-
You use the controller/model logic in the template. This is wrong way.
- [Django]-Django Programming error column does not exist even after running migrations
- [Django]-Log in user using either email address or username in Django
- [Django]-Django – update model with FormView and ModelForm
1
I used custom helper function with stripping. Here is a an example I used too: https://web.archive.org/web/20140729182917/http://cramer.io/2008/12/01/spaceless-html-in-django/
- [Django]-How to clear the whole cache when using django's page_cache decorator?
- [Django]-Django-DB-Migrations: cannot ALTER TABLE because it has pending trigger events
- [Django]-Django TypeError: render() got an unexpected keyword argument 'renderer'
Source:stackexchange.com