我正在尝试在我的项目中使用allauth和rest-auth,并尝试使用allauth中的内置函数来进行电子邮件验证,但这就是我得到的:
这是我的代码
设置.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/