Comments (8)
Our solution was a post transition signal to save the new state upon successful state change:
from django_fsm.signals import post_transition
@receiver(post_transition, sender=models.MyModel)
def save_new_workflow_state(sender, instance, name, source, target, **kwargs):
""" Save the new workflow state following successful django_fsm transition. """
if source != target:
instance.save()
from django-fsm.
Yep, it was removed in 2014 with django-fsm 2.0 release.
The recommended way for today is to switch to django-viewflow==2.0.0a and explicitly define desired behavior with .on_success
decorator - https://docs-next.viewflow.io/fsm/models.html
from django-fsm.
What is the recommandation if we want to stick with django-fsm package?
from django-fsm.
@xavella thanks for sharing! Is there a way to write this once for all models?
I can already see a new developer joining our codebase, adding a new Django Model and asking "why my model is not saved"? :)
from django-fsm.
I wouldn't take that approach as it would also apply to the admin models, which I don't see any reason to restrict track. How many models?
from django-fsm.
I'm not sure to understand the issue with admin models, as only my custom models have FSMField and transitions configured (except if a package is using django-fsm behind the scene ?).
Lots of models (more than 10) will need transitions. If I can do it, I'd like to avoid the manual step to add a signal for each of them, as it could be error-prone, and it's not DRY.
from django-fsm.
I would do this long-hand, not sure how to abstract the signal but maybe there is a way.
from django-fsm.
it seems ok following these steps:
- removing the sender parameter from within the decorator (means all senders are accepted)
- moving the signal to
signals.py
into my app - importing it using the ready() method
from django-fsm.
Related Issues (20)
- State changing through a management command HOT 1
- Do there any blockers to bump new release? HOT 7
- How to handle `can_proceed(transition) == False` HOT 1
- Future support HOT 1
- Support for Django 4.0 HOT 1
- documentation request HOT 1
- any new update in django-fsm HOT 1
- How can I have multiple workflows in the same template? HOT 4
- Question: How to resolve ConcurrentTransition(βCannot save object! The state has been changed since fetched from the database!β) issue ? HOT 1
- GitHub releases HOT 2
- Support for Django 4.0 when drawing transitions HOT 1
- graph_transitions: TypeError: expected string or bytes-like object HOT 3
- Update package to support Django 4 HOT 4
- No active CI for the builds HOT 7
- graph_transitions raise exception > TypeError: requires_system_checks must be a list or tuple HOT 6
- django_fsm.TransitionNotAllowed HOT 1
- Allowing incorrect state transitions HOT 3
- Releasing new version HOT 13
- Question: How to deal with async errors of side effects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-fsm.