【发布时间】:2021-12-23 23:01:02
【问题描述】:
有可能得到Django模型中的最后n个项目,使用反向关系。
{% for brand in brands %}
{% for product in brand.product_set.all %}
{% endfor %}
{% endfor %}
我尝试过这种方式,但它会打印所有内容。但只想要最后 3 项
【问题讨论】:
标签: python python-3.x django django-models django-templates