找不到与“ account_email_verification_sent”相反的内容。 'account_email_verification_sent'不是有效的视图函数或模式名称 [英] Reverse for 'account_email_verification_sent' not found. 'account_email_verification_sent' is not a valid view function or pattern name

查看:183
本文介绍了找不到与“ account_email_verification_sent”相反的内容。 'account_email_verification_sent'不是有效的视图函数或模式名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在项目中使用allauth和rest-auth,并尝试在allauth中使用内置功能来进行电子邮件验证,但这是我得到的:

I'm trying to use allauth and rest-auth in my project and try to use the built-in function in allauth to do email verification but this what I get :

这是我的代码

settings.py

settings.py

ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_REQUIRED = True

urls.py

urlpatterns = [
re_path(r'^', include('rest_auth.urls')),
re_path(r'^registration/', include('rest_auth.registration.urls')),
]


推荐答案

我找到了解决方案,我必须添加URL才能向后端发出发布请求以发送电子邮件,然后添加带有正则表达式的URL,该正则表达式具有将验证帐户和URL的令牌,并且添加名称为account_login的登录URL和名称为account_signup的注册URL,如下所示:

I found the solution, that I have to add URL to be able to make a post request to the backend to send email then URL with regex which has the token that will verify the account and URLs and add URL for login with name account_login and URL for register with name account_signup and be like this :

from rest_auth.registration.views import VerifyEmailView, RegisterView


urlpatterns = [
path('', include('rest_auth.urls')),
path('login/', LoginView.as_view(), name='account_login'),
path('registration/', include('rest_auth.registration.urls')),
path('registration/', RegisterView.as_view(), name='account_signup'),
re_path(r'^account-confirm-email/', VerifyEmailView.as_view(),
     name='account_email_verification_sent'),
re_path(r'^account-confirm-email/(?P<key>[-:\w]+)/$', VerifyEmailView.as_view(),
     name='account_confirm_email'),

]

这篇关于找不到与“ account_email_verification_sent”相反的内容。 'account_email_verification_sent'不是有效的视图函数或模式名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆