﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3860	AttributeError: 'module' object has no attribute 'myapp'	Vinay Sajip	Adrian Holovaty	"I wanted to get access to the User model in django.contrib.auth.models from within my app. My app (called myapp) has the following {{{__init__.py}}}:
{{{
import django.contrib.auth
print django.contrib.auth #to show this gets imported OK
import django.contrib.auth.models
}}}

When I run manage.py, I get an error:
{{{
vinay@zeta-dapper:~/projects/mysite$ ./manage.py sql myapp
<module 'django.contrib.auth' from '/usr/lib/python2.4/site-packages/django/contrib/auth/__init__.pyc'>
Traceback (most recent call last):
  File ""./manage.py"", line 11, in ?
    execute_manager(settings)
  File ""/usr/lib/python2.4/site-packages/django/core/management.py"", line 1680, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File ""/usr/lib/python2.4/site-packages/django/core/management.py"", line 1572, in execute_from_command_line
    translation.activate('en-us')
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 195, in activate
    _active[currentThread()] = translation(language)
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 184, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 167, in _fetch
    app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:])
  File ""/home/vinay/projects/mysite/../mysite/myapp/__init__.py"", line 3, in ?
    import django.contrib.auth.models
  File ""/usr/lib/python2.4/site-packages/django/contrib/auth/models.py"", line 4, in ?
    from django.contrib.contenttypes.models import ContentType
  File ""/usr/lib/python2.4/site-packages/django/contrib/contenttypes/models.py"", line 33, in ?
    class ContentType(models.Model):
  File ""/usr/lib/python2.4/site-packages/django/db/models/base.py"", line 30, in __new__
    new_class.add_to_class('_meta', Options(attrs.pop('Meta', None)))
  File ""/usr/lib/python2.4/site-packages/django/db/models/base.py"", line 169, in add_to_class
    value.contribute_to_class(cls, name)
  File ""/usr/lib/python2.4/site-packages/django/db/models/options.py"", line 53, in contribute_to_class
    setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', self.verbose_name + 's'))
  File ""/usr/lib/python2.4/site-packages/django/utils/functional.py"", line 42, in __wrapper__
    res = self.__func(*self.__args, **self.__kw)
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 255, in gettext
    _default = translation(settings.LANGUAGE_CODE)
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 184, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File ""/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py"", line 167, in _fetch
    app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:])
AttributeError: 'module' object has no attribute 'myapp'
}}}
This doesn't seem right: why should I be able to import django.contrib.auth but not be able to import django.contrib.auth.models? "	Uncategorized	closed	Contrib apps	dev	Normal	invalid		dev@…	Unreviewed	0	0	0	0	0	0
