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
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?
The text was updated successfully, but these errors were encountered:
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:
Fails as soon as I access any instance of
Order
model.What am I doing wrong?
The text was updated successfully, but these errors were encountered: