"account_email_verification_sent"的反向路径未找到。 "account_email_verification_sent"不是有效的视图函数或模式名称。

14
我正在尝试在我的项目中使用allauth和rest-auth,并尝试使用allauth中的内置函数进行电子邮件验证,但我得到了以下结果:

Link to screenshot of what I get

这是我的代码。

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

你读过http://django-rest-auth.readthedocs.io/en/latest/faq.html?highlight=account_confirm_email吗? - dukebody
抱歉,请查看 https://github.com/Tivix/django-rest-auth/issues/292#issuecomment-355099829 及相关内容。 - dukebody
命名为“account_email_verification_sent”的URL未包含在rest_auth.urlsrest_auth.registration.urls中。 - Oluwafemi Sule
你希望包含 django_allauthaccount.urls - Oluwafemi Sule
2个回答

24
我找到了解决方案,我必须添加一个URL才能通过后端进行帖子请求以发送电子邮件,其中包含具有将验证帐户和URL的令牌的正则表达式的URL,并添加一个名为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'),

]

0

我遇到了同样的问题,但我已经设置了电子邮件确认的URL,但我忘记了名称参数,这是必需的。

from django.conf.urls import url, include

from dj_rest_auth.registration.views import VerifyEmailView

urlpatterns = [
    url('auth/', include('dj_rest_auth.urls')),
    url('auth/registration/', include('dj_rest_auth.registration.urls')),
    url('auth/account-confirm-email/', VerifyEmailView.as_view(), name='account_email_verification_sent'),    
]
´´´

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接