django - django 电子邮件确认错误:TemplateResponseMixin 需要 'template_name' 或 'get_template_names()'
问题描述
我有一个带有 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),
]
有人可以帮我找出这个错误吗?我查看了许多其他在线发布的此问题的实例,并发现许多人通过使用正则表达式捕获注册确认路径来解决它,我已经尝试了在网上发布的解决方案中可以找到的所有正则表达式组合,但还没有有幸解决了这个问题。单击电子邮件确认链接时,我总是收到相同的错误。
非常感谢任何帮助,谢谢
解决方案
看来您查看需要定义allauthemailconfirmation
的用途。你没有。所以在你看来,添加它。就像是TemplateResponseMixin
template_name
class allauthemailconfirmation(TemplateResponseMixin, whateverClassesDeclared):
template_name = 'path/to/filename.html'
...
推荐阅读
- javascript - 带有字符串索引和.push()的Javascript 1D和2D数组?
- python - 如何在 Tensorflow 中打印出预测概率
- sql - 如何使用 DataGrip 在本地创建 postgre SQL 数据库
- hdfs - 使用 GDAL 在 HDFS 中打开栅格
- tfs - 升级到 SonarQube 6.7.5 后,在 TFS 2017 构建定义中运行 SonarQube 的代码分析任务失败
- loops - SSIS - 使用顶部处理批次
- ios - 在 UIStackView 中增加 UIButton 的面积
- asp.net-mvc - 在 Visual Studio 上运行网站项目在本地因 http 404 未找到页面错误而失败
- java - 将多个 RecyclerView 与一个 Adapter 类一起使用
- typescript - 由于未定义的属性,地图失败