From 7eeba54acb8ef9a654fd18547fcb3d93c69ca9b2 Mon Sep 17 00:00:00 2001 From: Pascal F Date: Fri, 13 Jun 2025 16:28:49 +0200 Subject: [PATCH] Update Readme --- README.md | 19 +++++++++++++++++-- tests/testapp/tests/test_multidecorators.py | 6 +++--- tests/wsgi.py | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3056e52..882ea49 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Nice introduction is available here: ## Installation +First, install the package with pip. + ``` bash $ pip install django-fsm-2 ``` @@ -39,6 +41,16 @@ Or, for the latest git version $ pip install -e git://github.com/django-commons/django-fsm-2.git#egg=django-fsm ``` +Register django_fsm in your list of Django applications + +```python +INSTALLED_APPS = ( + ..., + 'django_fsm', + ..., +) +``` + ## Migration from django-fsm django-fsm-2 is a drop-in replacement, it's actually the same project but from a different source. @@ -397,8 +409,9 @@ practically negating their effect. Renders a graphical overview of your models states transitions -You need `pip install "graphviz>=0.4"` library and add `django_fsm` to -your `INSTALLED_APPS`: +1. You need `pip install "graphviz>=0.4"` library + +2. Make sure `django_fsm` is in your `INSTALLED_APPS` settings: ``` python INSTALLED_APPS = ( @@ -408,6 +421,8 @@ INSTALLED_APPS = ( ) ``` +3. Then you can use `graph_transitions` command: + ``` bash # Create a dot file $ ./manage.py graph_transitions > transitions.dot diff --git a/tests/testapp/tests/test_multidecorators.py b/tests/testapp/tests/test_multidecorators.py index ee4c629..d071187 100644 --- a/tests/testapp/tests/test_multidecorators.py +++ b/tests/testapp/tests/test_multidecorators.py @@ -8,7 +8,7 @@ from django_fsm.signals import post_transition -class TestModel(models.Model): +class MultiDecoratedModel(models.Model): counter = models.IntegerField(default=0) signal_counter = models.IntegerField(default=0) state = FSMField(default="SUBMITTED_BY_USER") @@ -24,12 +24,12 @@ def count_calls(sender, instance, name, source, target, **kwargs): instance.signal_counter += 1 -post_transition.connect(count_calls, sender=TestModel) +post_transition.connect(count_calls, sender=MultiDecoratedModel) class TestStateProxy(TestCase): def test_transition_method_called_once(self): - model = TestModel() + model = MultiDecoratedModel() model.review() assert model.counter == 1 assert model.signal_counter == 1 diff --git a/tests/wsgi.py b/tests/wsgi.py index 0bea679..9817057 100644 --- a/tests/wsgi.py +++ b/tests/wsgi.py @@ -12,6 +12,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "silvr.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") application = get_wsgi_application()