简体   繁体   中英

How to show a Many-to-Many field in my django HTML Template?

I have one many to many field in my model.py

in that case i'm getting data as a queryset. But i want data as list. How to achieve that?

It is because there are more than one variable in Developer model. I think you are showing your data in a table data for that to work you should assign a str (self) function for the Developer model as it is mentioned below link:

django display content of a manytomanyfield

I hope it is clear.

This will work

{% for rt in JIRA %}
{% for dev in rt.Developer.all %}
<td>{{dev}} </td>
{% endfor %}
{% endfor %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM