Problem with django templates
Is there any s开发者_如何学Colution to do something like this:
{% for c in categories %}
{% for s in c.subcategory_set %}
<li>{{ s.name }}</li>
{% endfor %}
{% endfor %}
???
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 %}
精彩评论