gpt4 book ai didi

python - 邮件确认错误 rest-auth

转载 作者:行者123 更新时间:2023-12-05 01:45:53 28 4
gpt4 key购买 nike

我对确认电子邮件使用标准格式:从 allauth.account.views 导入 confirm_email 作为 allauthemailconfirmation

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^accounts/', include('allauth.urls')),
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')),

]

设置:

LOGIN_REDIRECT_URL='/'
ACCOUNT_EMAIL_VERIFICATION='mandatory'
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = False

我正确地收到了一封电子邮件,但是当您尝试链接时:

ImproperlyConfigured at /rest-auth/registration/account-confirm-email/MTU:1bn1OD:dQ_mCYi6Zpr8h2aKS9J9BvNdDjA/
TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'

最佳答案

我想我发现了你的问题。

这个网址:

/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'),

所以,你应该覆盖这个 View ,否则你会得到你遇到的错误,如下所述:https://github.com/Tivix/django-rest-auth/issues/20

您确实尝试过覆盖 View ,但是您的匹配模式是错误的,: char 导致它失败,所以让我们尝试类似

url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', allauthemailconfirmation, name="account_confirm_email"), 

相关部分是:(?P[-:\w]+)/$

关于python - 邮件确认错误 rest-auth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39658373/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com