【发布时间】:2010-10-26 06:03:36
【问题描述】:
我有一个模型,它有一个名为“state”的字段:
class Foo(models.Model):
...
state = models.IntegerField(choices = STATES)
...
对于每个状态,可能的选择是所有状态的某个子集。例如:
if foo.state == STATES.OPEN: #if foo is open, possible states are CLOSED, CANCELED
...
if foo.state == STATES.PENDING: #if foo is pending, possible states are OPEN,CANCELED
...
因此,当 foo.state 更改为新状态时,其可能的选择集也会更改。
如何在管理员添加/更改页面上实现此功能?
【问题讨论】:
标签: python django django-models django-admin