Reputation: 6540
Is there any solution to do something like this:
{% for c in categories %}
{% for s in c.subcategory_set %}
<li>{{ s.name }}</li>
{% endfor %}
{% endfor %}
???
Upvotes: 0
Views: 48
Reputation: 799580
Reverse relations on a FK have a manager. As such, you need to use the all()
method if you want to access all related objects.
{% for s in c.subcategory_set.all %}
Upvotes: 3