djangodjango-signalsdjango-apps

Django: Signal/Method called after "AppConfig.ready()"


I have an AppConfig.ready() implementation which depends on the readiness of an other application.

Is there a signal or method (which I could implement) which gets called after all application ready() methods have been called?

I know that django processes the signals in the order of INSTALLED_APPS.

But I don't want to enforce a particular ordering of INSTALLED_APPS.

Example:

INSTALLED_APPS=[
   'app_a',
   'app_b',
   ...
]

How can "app_a" receive a signal (or method call) after "app_b" processed AppConfig.ready()?

(reordering INSTALLED_APPS is not a solution)


Solution

  • I'm afraid the answer is No. Populating the application registry happens in django.setup(). If you look at the source code, you will see that neither apps.registry.Apps.populate() nor django.setup() dispatch any signals upon completion.

    Here are some ideas:

    If any of these approaches work for you obviously depends on what exactly you are trying to achieve.