Reading the posts on App reconfigure reminded me I wanted to raise this for discussion.
Recently we've been suffering circular imports, and the majority are, IMHO, caused by people importing "receivers" in the apss __init__.py.
By convention [in our app, at least] "receivers.py" registers all the signal receivers.
However, as Aymeric points out, puttng code in __init__ is a prime candidate for triggering circular imports.
A lot of times we can avoid the problems by breaking the loops with get_model(), however it generally gets applied elsewhere. We can't always do this in models.py, because often that would require importing other models, and I avoid that as much as possible.
So I tried an autodiscover mechanism, just admin, to make it clean, clear and obvious as to when all the receivers were hooked.
But...
When to run it?
If I put it in urls.py, like admin.autodiscover, can I be sure it will be triggered for, say, my celery tasks? Or management commands? I could put it at the end of settings.py, but that just feels wrong.
I'm happy to trace the whole of Django from go to whoa, and decide on a place to put it, but I'd like to hear from the community in general for ideas.
--
Curtis