70
Do you mean –
{% for d in data %}
{% if forloop.last %}
{{ d }}
{% else %}
{{ d }},
{% endif %}
{% endfor %}
have a look at the django docs on template for loops
13
Use {{ data|join:", " }}
, it does exactly what you need.
https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#join
- [Django]-Unique fields that allow nulls in Django
- [Django]-Django reverse lookup of foreign keys
- [Django]-Can someone explain how contribute_to_class works?
11
Or you can try this as well –
{% for d in data %}
{{ d }} {% if not forloop.last %},{% endif %}
{% endfor %}
have a look at the docs on template for loops
- [Django]-Django, ReactJS, Webpack hot reload
- [Django]-How do you limit list objects template side, rather than view side
- [Django]-How to add Check Constraints for Django Model fields?
Source:stackexchange.com