如何填充(链式)依赖下拉列表

时间:2019-08-22 11:24:27

标签: django chaining

我想根据父级连击的选择来填充从属连击。我的代码如下:

AddPlatformCommandClicked()

从django.contrib导入管理员

从.models导入Species,SpeciesDetail,Pair,

在这里注册您的模型。

class Species(models.Model):
    name = models.CharField(max_length=120, blank=False, null=False)
    description = models.TextField(max_length=300, blank=False, null=False)

class SpeciesDetail(models.Model):
    species = models.ForeignKey(Species, on_delete=models.CASCADE)
    picture = models.ImageField(upload_to='pics')
    gender = models.CharField(max_length=1)
    health = models.CharField(max_length=120)


class Pair(models.Model):
    species = models.ForeignKey(Species, on_delete=models.CASCADE)
    male = models.ForeignKey(SpeciesDetail, on_delete=models.CASCADE, related_name='male_set')
    female = models.ForeignKey(SpeciesDetail, on_delete=models.CASCADE, related_name='female_set')

1 个答案:

答案 0 :(得分:0)

答案是DAL(Django Autocomplete Light。