drf-knox和dr-auth注册问题

时间:2018-09-26 23:51:46

标签: python django django-rest-framework django-rest-auth

我正在学习drf,并且试图在django-rest-auth中使用knox。登录正常,但是注册部分出现问题。当我调用api使用localhost:8000 / rest-auth / registration添加新用户时,我填写了表单,但随后返回

  / pest-auth / registration /中的

AttributeError   类型对象“令牌”没有属性“对象”

我不知道为什么:/ 这是我的settings.py文件:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'rest_framework',

'rest_auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',

'knox',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication',),
}

SITE_ID = 1

这是我的urls.py文件:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('rest-auth/', include('rest_auth.urls')),
    path('rest-auth/registration/', include('rest_auth.registration.urls')),
]

错误在哪里?我该如何解决?谢谢您的帮助; D

0 个答案:

没有答案