我想能够设置访问一个领域的基础上选择的前一个领域在同一个模型。理想情况下,它可以在管理界面中使用。在
我的模型看起来是这样的:
GENDER_CHOICES = (
('f', 'Female'),
('m', 'Male'),
)
class Animal(models.Model):
name = models.CharField(max_length=255)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
is_castrated = models.BooleanField()
def __unicode__(self):
return self.name
我是否可以限制对is_castrated
字段的访问,使其仅在用户从gender字段中选择了Male
时才可用?在
听起来你需要一些javascript。 你可以通过在管理员py文件。 看看这个:
相关问题 更多 >
编程相关推荐