【发布时间】:2021-11-14 04:27:51
【问题描述】:
我已经安装了dj-rest-auth用于令牌认证。
我的 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',
]
我的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
但是当我尝试 runserver 它给了我
NameError:名称“dj_rest_auth”未定义
我做错了什么?
【问题讨论】:
标签: django authentication django-rest-framework