8
Since ManyToMany returns a queryset, you need to loop through the queryset.
You can access the queryset this way: {{ listing.tag.all }}
and you can access it this way
{% for tag in listing.tag.all %}
{{tag.name}}
{% endfor %}
1
You should loop through your set of tags:
{% for tag in listing.tag.all %}
{{ tag.name }}
{% endfor %}
- [Django]-How to convert normal numbers into arabic numbers in django
- [Django]-Find out Python version from source code (or Heroku)
- [Django]-Django creates the test database for Postgresql with incorrect sequences start values
- [Django]-How do I make Django admin URLs accessible to localhost only?
- [Django]-Django URLs without function in views
0
If you just need __str__
(or equivalent) and a simple join, this will work:
{{ listing.tag.all|join: ", "}}
Reference: https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#join
Source:stackexchange.com