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


If I created django in the login view as the following code

  Django.conf Import import pattern, include, django.contrib.auth.views import urlpatterns = pattern (url (r'login / $ ', login, name =' login ') URL),   

Everything works fine, but if I include it in the following way import code from , import url from django.contrib auth urlpatterns = 'pattern (' ', Url (r'login / $', auth.views.login, name = 'login'),)

I get the following error

  Exception value: 'module' object has no attribute 'witch R '  

Who's really bothers me that he is in any other project I've been imported from the other way and it is working fine. Does anyone know what's going on here?

In another project you probably already call the auth.views module auth.views.login before you can. The python will split your imported module, when it can happen.

For example, this will work

  & gt; & Gt; & Gt; Django.contrib.auth.views Import Login # or django.contrib.auth from import views & gt; & Gt; & Gt; Django.contrib Import with Evaluation & gt; & Gt; & Gt; Auth.views.login & lt; Function Login 0x02C37C30 & gt;   

The first import is not even mentioned in the login view. This will also work.

  & gt; & Gt; & Gt; From Django.contrib.auth.views import logout ... #then import auth.views.login   

The following is because the Python views module because it auth .__ init __ Py

  & gt; & Gt; & Gt; Not registered in Django.contrib Import with Evaluation & gt; & Gt; & Gt; Auth.views.login ... Features: There is no attribute 'idea' in the 'module' object    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -