0

I have an app companies. Inside the app there is a file called signals.py with the following code:

post_save.connect(update_descendants, sender=Company)

Inside companies apps.py I have:

class CompaniesConfig(AppConfig):
    name = 'apps.companies'

    def ready(self):
        from . import signals

But the signals are not imported/called.

If I import the file in models.py it work but it creates a circular import issue, and I need to this imports inside functions not at top.

Structure:

 - companies
   -apps
   -models
   -signals

Why app config is not working ?

J Mo
  • 43
  • 6

3 Answers3

1

If you are using a custom AppConfig class then you need to tell Django about it. It isn't automatically discovered. Reference in in the Django settings files like this:

INSTALLED_APPS [
    ....
    "companies.apps.CompaniesConfig",
    ....
]
timop
  • 842
  • 6
  • 7
1

You need to add the appconfig in app's init.py:

default_app_config = 'apps.companies.CompaniesConfig'

This is along with the ready() in AppConfig which I see you already have in apps.py

b2rules
  • 11
  • 1
0

You may need to add an __init__.py file to the companies directory...

__init__.py can just be a blank file with that name.