#3860: AttributeError: 'module' object has no attribute 'myapp'
-----------------------------------------+----------------------------
Reporter: Vinay Sajip | Owner: adrian
Type: Uncategorized | Status: closed
Milestone: | Component: Contrib apps
Version: SVN | Severity: Normal
Resolution: invalid | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
-----------------------------------------+----------------------------
Changes (by eternicode):
* type: => Uncategorized
* severity: => Normal
Comment:
Sorry to comment on a 4-year-old thread, but this is the first google
result for this issue, no apparent resolution was reached here, and the
django-users discussion (if there was one) is not linked :)
The problem is that {{{myapp/__init__.py}}} imports {{{auth.models}}} when
it's executed; at this point, the subpackage {{{myapp}}} of {{{mysite}}}
has not yet been imported, and is not yet an attribute on the parent
package ({{{mysite.myapp}}} doesn't exist yet). {{{auth.models}}},
though, imports and invokes the translation framework, which in turn tries
to import each of {{{INSTALLED_APPS}}} by importing the app's parent
package ({{{django.contrib}}} or {{{mysite}}}) and doing a {{{getattr}}}
for the app package -- ie, effectively {{{getattr(mysite, 'myapp')}}}.
It's some kind of circular dependency breakdown.
The solution is 1) not import things that use the translation framework
from an app's {{{__init__.py}}} or 2) delay the import until after all
apps have been imported.
--
Ticket URL: <http://code.djangoproject.com/ticket/3860#comment:7>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.