Django viewflow: not receiving flow_finished signal

101 views Asked by At

I'm trying to catch the flow_finished signal from django viewflow like this

flow_finished.connect(function)

but it's not working. The function isn't called even if the flow finishes. Any help please, I'm pretty lost.

In my app's init.py I added this

from django.apps import AppConfig


default_app_config = 'test.TestConfig'


class TestConfig(AppConfig):
    name = 'test'
    verbose_name = 'Test'

    def ready(self):
        import viewflow.signals
1

There are 1 answers

1
kmmbvnr On BEST ANSWER

First, you need to ensure that you properly configured you app config, and the ready method really been called. Check your installed apps that you properly included your TestConfig, or if you use shortcuts, check you test/__init__.py default_app_config value

from viewflow.signals import flow_finished

def receiver(sender, **kwargs):
    print('hi')


class TestConfig(AppConfig):
    name = 'test'

    def ready(self):
        flow_finished.connect(receiver)

But generally, using signals to weave your codebase is a bad taste. To call an action before flow.End you can explicitly add flow.Handler. That's the recommended solution.