How can I use Django to remove spaces between tags and text?

I am using Django and I want to remove spaces after or before this block.

I found no spaces in django But only the space between the tags is deleted, not the space between the tags and the text.

Use jinja

{% for item in seq -%}
{{ item }}
{%- endfor %}

it removes spaces after or before this block.

How to use this function in Django?

+4
source share
1 answer

I am afraid this is not possible in django templates. If this is an HTML template, you can use this dirty hack:

{% for item in seq %}<!--
-->{{ item }}<!--
-->{% endfor %}
0
source

All Articles