Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"name 'django' not defined" error when using the generic login view?

I'm am trying to use the generic login view provided by django and this is my urls.py:

url(r'^login/$', django.contrib.auth.views.login),

When I run the server and go to

127.0.0.1 

it gives me a

NameError at /

saying

name 'django' is not defined

when I remove 'django' and just leave it at

contrib.auth.views.login

it gives a

NameError at /

saying

name 'contrib' is not defined

any idea why and how to fix this?

like image 603
SilentDev Avatar asked Jan 11 '23 11:01

SilentDev


1 Answers

Instead of django.contrib.auth.views.login, try at the top of your urls.py stating: from django.contrib.auth import views. Then, in your url login pattern, where you originally put django.contrib.auth.views.login, replace it with views.login. If this doesn't work, please post your full urls.py.

like image 143
Aurora Avatar answered Jan 16 '23 20:01

Aurora