Using spaceless in django template -
i have following code:
{% item in profile.jobs.all %} {% if not forloop.first %}, {% endif %}{{ item }} {% endfor %}
which produces following:
"programmer , plumber , philosopher"
i not want leading space before comma, way i've been able rid of compress onto 1 line, reduces readability:
{% item in profile.jobs.all %}{% if not forloop.first %}, {% endif %}{{ item }}{% endfor %}
is there better way deal this?
{% spaceless %} strips spaces between html tags.
you can either use {{ value|join:", " }}
or believe work:
{% item in profile.jobs.all %} {% if not forloop.first %}, {% endif %} {{ item }} {% endfor %}
Comments
Post a Comment