我有以下模板
{% regroup product.hotel.facilities.all by facilitytype as facilities %}
{% for facility in facilities %}
<h5>{{ facility.grouper }}</h5>
<p class="tab-content-title bld">
{% for i in facility.list %}
<li>{{ i }}</li>
{% endfor %}
{% endfor %}
以下模型结构:
class Hotel(TranslatableModel):
code = models.CharField(max_length=255)
facilities = models.ManyToManyField('hotels.Facility',null=True)
class Facility(TranslatableModel):
code = models.CharField(max_length=255, unique=True)
facilitytype = models.ForeignKey(FacilityType, null=True, blank=True)
translations = TranslatedFields(
name=models.CharField(max_length=255, blank=True),
)
但是当我运行页面时,我会在下面看到。相反,我想看看由facility_types分组和区分的列表: 有任何想法吗?
答案 0 :(得分:3)
您必须首先按发布者字段对数据进行排序。