Django admin:如何根据另一个选择框限制相关的选择框值

时间:2012-05-01 09:14:25

标签: django django-admin

class Products(models.Model):
    name = models.CharField(max_length=50)

    leve1 = models.ForeignKey( Level1 )
    leve2 = models.ForeignKey( Level2 )
    leve3 = models.ForeignKey( Level3 )
    leve4 = models.ForeignKey( Level4 )



class Level1(models.Model):
    name = models.CharField(max_length=50)

class Level2(models.Model):
    name = models.CharField(max_length=50)
    leve1 = models.ForeignKey( Level1 )

class Level3(models.Model):
    name = models.CharField(max_length=50)
    leve2 = models.ForeignKey( Level2 )

class Level4(models.Model):
    name = models.CharField(max_length=50)
    leve3 = models.ForeignKey( Level3 )

在Django Admin中根据另一个选择框优化选择框值

使用formfield_for_foreignkey? raw_id_fields?

1 个答案:

答案 0 :(得分:1)