2

我有这个模型:

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 模板?

如果后者属实,请给我一些指点。非常感谢。

4

0 回答 0