Hi guys !
First of all, i’m new here, so if this issue has already been discussed or if here is not the place to talk about it please don’t hesitate to tell me. Also, please be aware English is not my first language.
I would want to discuss about signals and how they are loaded in Django.
Very often, i create my
signals.py, write my signal and wonder for a while why it does not work. Of course, the file is not imported and so never even read by python !
So i create an
apps.py, on this template :
from django.apps import AppConfig class CustomAppConfig(AppConfig): name = "app.subapp" def ready(self): import app.subapp.signals
I would like to sugest importing
signals.py automatically at app loading (maybe
- no more wandering for hours what is the problem here
- no more boilerplate
- file with signals would have to be named
- maybe some rely on the file being imported when they decided ? (don’t see a use case here, specially when loading signals does not equals activating them)
If loading (and so activating) signals is too mush of a change, maybe others solutions will fix my problem. For know, all I can think of :
- Log if a
signals.pyfile is detected but the
AppConfigis not overriden (but we would not know if imported elsewhere)
- Log how many signals are detected for the app (but from a dozen apps the log will be too heavy to be read)
- not really an alternative, but the loading could be conditionnal to a project-wide setting
i would like to know if this would benefits others (I think so) and if it is worthy of filing an Issue