我有这个型号:
class IllnessMedication(models.Model):
FREQUENCY_CHOICES = (
('D', 'Day'),
('W', 'Week'),
('M', 'Month'),
)
NUMERIC_CHOICES = (
(1, 1),
(2, 2),
(3, 3),
(4, 4),
)
illness = models.ForeignKey(Illness)
medication = models.ForeignKey(Medication)
strength = models.CharField("strength", max_length=25)
dosage = models.IntegerField("dosage", choices=NUMERIC_CHOICES)
class Meta:
db_table = "medication_illness"
class Medication(models.Model):
value = models.CharField("medication", max_length=50)
class Meta:
db_table = "medication"
class Illness(models.Model):
value = models.CharField("code", max_length=10)
description = models.CharField("description", max_length=100)
class Meta:
db_table = "illness"
我想按时间分组显示列表视图,即
Illness1
Medication11
Strenght1 Dosage1
Strenght2 Dosage2
Strenght3 Dosage3
Medication12
Strenght1 Dosage1
Strenght2 Dosage2
Strenght3 Dosage3
Illness2
Medication21
Strenght1 Dosage1
..................
这可以通过使用可用的Django安装的选项/功能/等调整django admin Model和ModelAdmin来实现,或者我应该认真努力覆盖change_list.html模板吗?
如果后者属实,请给我一些指示。非常感谢。
尼奇