【发布时间】:2019-12-19 08:30:41
【问题描述】:
我有一个带有 customUser 模型(电子邮件/密码)的 django 项目,我正在尝试让电子邮件验证链接正常工作。他们以前一直在工作,但现在由于某种原因,路径失败了。当您在我的网站上注册一个帐户时,您会收到一封包含注册确认 URL 的电子邮件,如下所示:
http://127.0.0.1:8000/rest-auth/registration/account-confirm-email/OA:1hxEiC:mbXKk8-is0YJz2FKHd_1d62KNv8/
但是当你点击这个 url 时,它会导致一个带有消息的错误页面:
ImproperlyConfigured at /rest-auth/registration/account-confirm-email/OA:1hxEiC:mbXKk8-is0YJz2FKHd_1d62KNv8/
TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
我的主 urls.py 文件有一个 urlpatterns 列表,如下所示:
urlpatterns = [
#admin page
path('admin/', admin.site.urls),
path('playlist/', include(('playlist.urls', 'playlist'), namespace='playlist')),
#users
path('users/', include('django.contrib.auth.urls')),
#accounts (allauth)
path('accounts/', include('allauth.urls')),
...
#django-rest-auth
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
#bug reports for this issue online point to a solution like so, but this isn't fixing the error
url(r"^rest-auth/registration/account-confirm-email/(?P<key>[\s\d\w().+-_',:&]+)/$", allauthemailconfirmation, name="account_confirm_email"),
#jwt
url(r'^refresh-token/', refresh_jwt_token),
]
有人可以帮我找出这个错误吗?我查看了许多其他在线发布的此问题的实例,并发现许多人通过使用正则表达式捕获注册确认路径来解决它,我已经尝试了在网上发布的解决方案中可以找到的所有正则表达式组合,但还没有有幸解决了这个问题。当我点击电子邮件确认链接时,我总是收到同样的错误。
非常感谢任何帮助,谢谢
【问题讨论】:
标签: django django-templates django-urls django-allauth django-email