I have a field in my module that is used to hold the status of the object. So far I have used:
ORDER_STATUS = ((0, 'Started'), (1, 'Done'), (2, 'Error'))
status = models.SmallIntegerField(choices=ORDER_STATUS)
Its easy to convert one way:
def status_str(self): return ORDER_STATUS[self.status][1]
The problem is when updating. I find myself having code like this:
order.status = 2 # Error Status
Which is quite awful and gets really hard to synchronize. I guess a solution would be something similar to C's enum{}. Or perhaps there is a whole different way to tackle this problem ?
Thanks