未找到“account_email_verification_sent”的反向。 'account_email_verification_sent'不是有效的视图函数或模式名称

时间:2018-01-22 21:44:41

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

我正在尝试在我的项目中使用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')),
]

1 个答案:

答案 0 :(得分:5)

我找到了解决方案,我已经添加了网址,以便能够发送电子邮件后发送电子邮件,然后使用regx进行网址,其中包含将验证帐户和网址的令牌,并使用名称account_login和网址添加用于登录的网址注册名称为account_signup,如下所示:

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

]