django - 未找到 'account_email_verification_sent' 的反向。 'account_email_verification_sent' 不是有效的 View 函数或模式名称

标签 django django-rest-framework django-allauth django-rest-auth

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

Link to screenshot of what I get

这是我的代码

设置.py

ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_REQUIRED = True

url.py

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

最佳答案

我找到了解决方案,我必须添加一个 URL,以便能够向后端发出发布请求以发送电子邮件,该 URL 带有正则表达式,其中包含将验证帐户和 URL 的 token ,并添加使用名称 account_login 登录的 URL 和使用名称 account_signup 注册的 URL 如下所示:

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

]

关于django - 未找到 'account_email_verification_sent' 的反向。 'account_email_verification_sent' 不是有效的 View 函数或模式名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48390749/

相关文章:

python - 对在 GAE 上托管 OSQA/Django 的担忧

python - 获取错误 : Object of type User is not JSON serializable in django python

python - 如果电子邮件已确认,django jwt 会生成 token

django - 使用电话或电子邮件登录/注册 django、allauth 集成

html - django allauth 自定义消息 : Styling messages with html/css

django - django 启动时使用 paramiko 来隧道化 MySql 端口

Django LDAP 与 OpenWisp Django-IPAM

django - 如何在 django-admin-tools 仪表板上添加自定义菜单项

python - 如何从 Django 的复选框中获取值数组

python - DRF - 编写双嵌套序列化程序的更好方法