My code is as follows...
class Todo(models.Model):
state_choice = (('To Do','To Do'),('Doing','Doing'),('Done','Done'))
def get_color_depends_state(self):
if self.state:
if self.state == 'To Do':
self.color_code = '87CEEB'
elif self.state == 'Doing':
self.color_code = '7D3C98'
elif self.state == 'Done':
self.color_code = '00FF7F'
state = models.CharField(max_length=200,choices=state_choice,default='todo')
color_code = models.CharField(max_length=6, default=self.get_color_depends_state)
My field color_code depends on the values of state field. I am trying to call the function from the color_code field but it is giving errors like self not defined or module has no attribute get_color_depends_state.
How I can call an instance method from field which intern depends on other field values(Here state)