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

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -