Reputation: 417
I have installed dj-rest-authfor Token Authentication.
My urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('customer/', include('customer.urls')), #new
path('api-auth/', include('rest_framework.urls')), # new
path('customer/dj-rest-auth/', include(dj_rest_auth.urls)),
]
Settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'customer',
'rest_framework.authtoken', # new
'dj_rest_auth',
]
My Requirements.txt:
asgiref==3.4.1
dj-rest-auth==2.1.11
Django==3.2.7
django-rest-auth==0.9.5
djangorestframework==3.12.4
psycopg2-binary==2.9.1
pytz==2021.1
six==1.16.0
sqlparse==0.4.2
But when I am trying to runserver It's giving me
NameError: name 'dj_rest_auth' is not defined
What am I doing wrong?
Upvotes: 0
Views: 257
Reputation: 10709
As documented, you should include it as a string "dj_rest_auth.urls"
and not dj_rest_auth.urls
from which it fails to find where dj_rest_auth
is defined:
path('dj-rest-auth/', include('dj_rest_auth.urls'))
This is aligned with the usage of django.urls.include() which expects it to be the module name.
Upvotes: 1