I have a model that has a field named "state":
class Foo(models.Model):
...
state = models.IntegerField(choices = STATES)
...
For every state, possible choices are a certain subset of all STATES. For example:
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
...
As a result, when foo.state changes to a new state, its set of possible choices changes also.
How can I implement this functionality on Admin add/change pages?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…