forked from oxplot/fysom
-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
Hi!
I tried the example described in the manual to have a global states machine for a Django class.
Copy-pasting the exact sample fails in Django 1.11 with: TypeError: __init()__ takes 1 positional argument but 30 were given
Below is my code:
def after_transition(e):
# to test callbacks
print("AFTER transition")
def printstatechange(e):
# to test callbacks
print('event: %s, src: %s, dst: %s' % (e.event, e.src, e.dst))
def welcome_back(e):
# to test callbacks
print("welcome back!")
class Order(PaidModel, FysomGlobalMixin, models.Model):
GSM = FysomGlobal(
events=[('open', 'complete', 'reset'),
{
'name': 'open',
'src': 'draft',
'dst': 'open',
},
{'name': 'complete', 'src': '*', 'dst': 'completed'},
{'name': 'reset', 'src': '*', 'dst': 'draft'},
],
initial='draft',
final='completed',
state_field='status',
callbacks={
'onopen': after_transition,
'onchangestate': printstatechange,
'onreenteropen': welcome_back,
}
)
def __init__(self):
self.status = None
super(Order, self).__init__()
status = models.CharField(
_('state'),
max_length=30,
blank=True, null=True,
)
# other fields
def __str__(self):
return str(self.id) # modified for this short example
Fails as soon as I access any instance of Order model.
What am I doing wrong?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels