django模板的问题

django模板的问题,django,templates,Django,Templates,有什么解决方案可以这样做: {% for c in categories %} {% for s in c.subcategory_set %} <li>{{ s.name }}</li> {% endfor %} {% endfor %} {%c在类别%} {c.subcategory_set%中的s的%s} {{s.name}} {%endfor%} {%endfor%} ??FK上的反向关系有一个管理器。因此,如果要访问所有相关对象,则需要使用

有什么解决方案可以这样做:

{% for c in categories %}
   {% for s in c.subcategory_set %}
   <li>{{ s.name }}</li>
   {% endfor %}
{% endfor %}
{%c在类别%}
{c.subcategory_set%中的s的%s}
  • {{s.name}}
  • {%endfor%} {%endfor%}

    ??FK上的反向关系有一个管理器。因此,如果要访问所有相关对象,则需要使用
    all()
    方法

    {% for s in c.subcategory_set.all %}
    

    FK上的反向关系有一个管理器。因此,如果要访问所有相关对象,则需要使用
    all()
    方法

    {% for s in c.subcategory_set.all %}
    

    就是这样。感谢Ypu从不睡觉,总是观察给出好的答案:)就是这样。感谢Ypu从不睡觉,总是观察给出好的答案:)