-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django & python-statemachine #348
Comments
Just saw that there is discussions in GH now, lmk if you'd rather have me ask there. Thanks! |
Hi @enilsen16 , This Can you provide more context on why you're passing this value? Understanding the underlying needs may help to suggest alternative implementation. The See how the mixin creates a StateMachine instance: https://github.com/fgmacedo/python-statemachine/blob/develop/statemachine/mixins.py#L38 machine_cls(self, state_field=self.state_field_name), So, trying to actually answer your question, you don't need to pass an additional model value to the state machine to use as condition, all model attributes, properties and methods are available by default. The SM uses process_order = processing.to(shipping, cond="payment_received") This is possible due to the v1.0 new The model is registered as an observer, so you can implement callbacks, conditions, virtually any state/transition hook on the model. Hope that this helps, let me know if works for you so we can close the issue. Best regards! |
|
Closing as an alternative implementation using the model without the need to pass additional parameters to the SM constructor. Docs improved at #352. Feel free to reopen if something is missing. |
Description
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
I'm writing a statemachine to track the state of a given entity and was hoping to use the mixin support for django models to make saving that state a little bit easier. However when I try to add something like this assuming my model is set up correct to use
MyStatemachine
,__init__() got an unexpected keyword argument 'state_field'
It doesn't seem to work with how the
Mixin
sets things up automatically. I'm wondering if you have any suggestions on the best way to do this?The text was updated successfully, but these errors were encountered: