我有以下模板
{% 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 分组和区分的列表:有什么想法吗?