I wonder if Django offers this feature some other web frameworks like Ruby on Rails do. I am talking about means to forbid certain states where the values of the attributes being saved, for example:
model.active = False
model.authorized = True
model.save() # this should fail
We can have a model
where both active
and authorized
are either both True
or False
, but we cannot have any other combination. Sorry but I can't think of a better example right now, I hope the intent is understood.
So, does Django have any means for handling these situations? Or implementing it ourselves when the method save
is called is the only way?