You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it would be great if when working with django we could do something like:
fromstatus_map.djangoimportStatusFieldclassTask(Model):
status=StatusField(status_map={'todo': ['doing'], 'doing': ['todo', 'done'], 'done': []})
title=CharField(...)
>>>task=Task(title='implement django support on status-map') # defaults to the first status passed (todo)>>>task.status='done'>>>task.save()
status_map.exceptions.TransitionNotFoundError: transitionfromtodotodonenotfound
instead of something like:
fromstatus_mapimportStatusMapTASK_STATUS_MAP=StatusMap({'todo': ['doing'], 'doing': ['todo', 'done'], 'done': []})
classTask(Model):
status=ChoiceField(choices=TASK_STATUS_MAP._map.keys(), default='todo')
# not using validators because I'm pretty sure we can't acess the current status on the dbdefsave(self, *args, **kwargs):
task=Task.objects.get(pk=self.pk)
iftask.status!=self.status:
TASK_STATUS_MAP.validate_transition(task.status, self.status)
returnsuper().save(*args, **kwargs)
The text was updated successfully, but these errors were encountered:
it would be great if when working with django we could do something like:
instead of something like:
The text was updated successfully, but these errors were encountered: