我想我发现了你的问题。
这个网址:
/rest-auth/registration/account-confirm-email/MTU:1bn1OD:dQ_mCYi6Zpr8h2aKS9J9BvNdDjA/
与此模式不匹配:
url(r'^rest-auth/registration/account-confirm-email/(?P<key>\w+)/$', allauthemailconfirmation, name="account_confirm_email"),
但通过以下方式:
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
如果你看一下源代码rest_auth.registration.urls
,你会看到这段代码:
# This url is used by django-allauth and empty TemplateView is
# defined just to allow reverse() call inside app, for example when email
# with verification link is being sent, then it's required to render email
# content.
# account_confirm_email - You should override this view to handle it in
# your API client somehow and then, send post to /verify-email/ endpoint
# with proper key.
# If you don't want to use API on that step, then just use ConfirmEmailView
# view from:
# django-allauth https://github.com/pennersr/django-allauth/blob/master/allauth/account/views.py#L190
url(r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(), name='account_confirm_email'),
因此,您应该覆盖此视图,否则您将收到错误,如下所述:https://github.com/Tivix/django-rest-auth/issues/20 https://github.com/Tivix/django-rest-auth/issues/20
您确实尝试过覆盖视图,但是您的匹配模式是错误的, : char 导致它失败,所以让我们尝试类似的方法
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', allauthemailconfirmation, name="account_confirm_email"),
相关部分是:(?P[-:\w]+)/$