'module' object has no attribute 'views' django error

nik

If I import django's built in login view as in following code

from django.conf.urls import patterns, include, url
from django.contrib.auth.views import login

urlpatterns = patterns('',    
    url(r'login/$', login, name='login'),
)

every thing works fine, but if I'll include it in following way

from django.conf.urls import patterns, include, url
from django.contrib import auth

urlpatterns = patterns('',    
    url(r'login/$', auth.views.login, name='login'),
)

I get the following error

Exception Value: 'module' object has no attribute 'views'

what is really bothering me is in another project I am importing it the second way and it is working fine. Does anyone know what's going on over here?

vikki

In the second project you've probably already imported the auth.views module before calling auth.views.login. Python stitches your imported modules when it can.

For example, this will work

>>> from django.contrib.auth.views import login #or from django.contrib.auth import views
>>> from django.contrib import auth

>>> auth.views.login
<function login at 0x02C37C30>

The first import doesn't even have to mention the login view. This will also work.

>>> from django.contrib.auth.views import logout
...
#then import auth.views.login

The following won't because python does not know of the views module since it isn't registered in auth.__init__.py

>>> from django.contrib import auth

>>> auth.views.login
...
AttributeError: 'module' object has no attribute 'views'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

AttributeError: 'module' object (scipy) has no attribute *** Why does this error occur?

From Dev

urllib module error! AttributeError: 'module' object has no attribute 'request'

From Dev

python error "AttributeError: 'module' object has no attribute 'sha1'"

From Dev

django signals module object has no attribute connect

From Dev

Django - 'module' object has no attribute 'BigIntegerField'

From Dev

Atrribute Error:'module"object has no attribute python 3.2

From Dev

Paramiko: Module object has no attribute error 'SSHClient'

From Dev

Python 3 error: 'module' object has no attribute 'split'

From Dev

Flask Blueprint AttributeError: 'module' object has no attribute 'name' error

From Dev

django 'User' object has no attribute 'get' error

From Dev

Chasing game - Error message: "'module' object has no attribute 'display'"

From Dev

Django won't start with a wierd error "AttributeError: 'module' object has no attribute 'getargspec'"

From Dev

Django Rest framework authtoken 'module' object has no attribute 'views'

From Dev

travic ci error AttributeError: 'module' object has no attribute 'hashpw'

From Dev

Django Attribute Error: object has not attribute 'forms'

From Dev

'module' object has no attribute 'SortedDict' Django Tastypie error

From Dev

'function' object has no attribute 'get' error in django

From Dev

Django JSON field. 'module' object has no attribute 'JSONField'

From Dev

'function' object has no attribute 'get' error in django

From Dev

Django 1.5 - 'module' object has no attribute 'simple_class_factory'

From Dev

django signals module object has no attribute connect

From Dev

Django Attribute Error: 'function' object has no attribute 'is_usable'

From Dev

Error: 'module' object has no attribute (ArcMap 10.1)

From Dev

AttributeError: 'module' object has no attribute 'error'

From Dev

'module' object has no attribute 'main' -- Django

From Dev

Python/DJango Attribute error : Model object has not attribute objects

From Dev

Django - AttributeError: 'module' object has no attribute 'admin'

From Dev

Django: "Form object has no attribute..." error

From Dev

Django error - 'function' object has no attribute 'MyForm'

Related Related

  1. 1

    AttributeError: 'module' object (scipy) has no attribute *** Why does this error occur?

  2. 2

    urllib module error! AttributeError: 'module' object has no attribute 'request'

  3. 3

    python error "AttributeError: 'module' object has no attribute 'sha1'"

  4. 4

    django signals module object has no attribute connect

  5. 5

    Django - 'module' object has no attribute 'BigIntegerField'

  6. 6

    Atrribute Error:'module"object has no attribute python 3.2

  7. 7

    Paramiko: Module object has no attribute error 'SSHClient'

  8. 8

    Python 3 error: 'module' object has no attribute 'split'

  9. 9

    Flask Blueprint AttributeError: 'module' object has no attribute 'name' error

  10. 10

    django 'User' object has no attribute 'get' error

  11. 11

    Chasing game - Error message: "'module' object has no attribute 'display'"

  12. 12

    Django won't start with a wierd error "AttributeError: 'module' object has no attribute 'getargspec'"

  13. 13

    Django Rest framework authtoken 'module' object has no attribute 'views'

  14. 14

    travic ci error AttributeError: 'module' object has no attribute 'hashpw'

  15. 15

    Django Attribute Error: object has not attribute 'forms'

  16. 16

    'module' object has no attribute 'SortedDict' Django Tastypie error

  17. 17

    'function' object has no attribute 'get' error in django

  18. 18

    Django JSON field. 'module' object has no attribute 'JSONField'

  19. 19

    'function' object has no attribute 'get' error in django

  20. 20

    Django 1.5 - 'module' object has no attribute 'simple_class_factory'

  21. 21

    django signals module object has no attribute connect

  22. 22

    Django Attribute Error: 'function' object has no attribute 'is_usable'

  23. 23

    Error: 'module' object has no attribute (ArcMap 10.1)

  24. 24

    AttributeError: 'module' object has no attribute 'error'

  25. 25

    'module' object has no attribute 'main' -- Django

  26. 26

    Python/DJango Attribute error : Model object has not attribute objects

  27. 27

    Django - AttributeError: 'module' object has no attribute 'admin'

  28. 28

    Django: "Form object has no attribute..." error

  29. 29

    Django error - 'function' object has no attribute 'MyForm'

HotTag

Archive