On Sun, Jan 26, 2014 at 8:54 PM, Aymeric Augustin <
[email protected]> wrote:

> Hello,
>
> Django ≥ 1.7 recommends to define AppConfig subclasses for a given
> application in apps.py.
>
> If the application also imports the app registry in its __init__.py with
> `from django.apps import apps`, this definition of `apps` will conflict
> with the `apps` submodule.
>
> I’ve worked around this problem in django.contrib.auth and
> django.contrib.comments (which is deprecated) with: `from django.apps
> import apps as django_apps`.
>
> If anything, this is one more reason why it’s a bad idea to put code in
> __init__.py. Given that we have a simple workaround, I’m inclined to simply
> ignore this pitfall.
>

I'm inclined to agree. Python imports can be complex when name clashes
occur; the best course of action is to just avoid the problem in the first
place.

It's worth documenting this as a gotcha in the app loading docs (with the
admonition of "this is why you don't put code in __init__.py"), but I don't
think we need to be overly concerned.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJxq84_C4h8D7irkdpEG56Nbb_mj55QzY-D_vq4N%3DwhvtVx-ng%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to