在/ rest-auth/registration/account-confirm-email上配置不正确

Sau*_*rma 7 python django django-allauth django-rest-auth

我正在使用django-rest-auth进行用户注册并验证电子邮件.我可以在用户注册时成功发送电子邮件.但是,对于电子邮件验证,我收到以下回溯的错误:

File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in dispatch
  87.         return handler(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in get
  155.         return self.render_to_response(context)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in render_to_response
  130.             template=self.get_template_names(),
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in get_template_names
  142.                 "TemplateResponseMixin requires either a definition of "

Exception Type: ImproperlyConfigured at /rest-auth/registration/account-confirm-email/vjohhnrf6xpkmn1jxbzaopdn0g79tdyofumeeuyuehcuja8slyz7nzq1idyifcqk/
Exception Value: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
Run Code Online (Sandbox Code Playgroud)

有关如何解决此问题的任何想法?

Ric*_*llo 6

使用确认电子邮件时,您有两种方法可以执行此操作.

使用API​​指定或创建您的API.默认情况下,它使用django-allauth,并且可以使用反向的TemplateView.

如果您创建自己的,则可能必须覆盖account_confirm_email,然后发布到verification_mail.

在urls.py中,它被定义为反向,因此,根据您要执行的操作,您将首先创建自己的account_confirm_email,获取所需的密钥并将其发布到verify-email.这里有关于这个bug的更多信息.


vel*_*lis 5

尽管里卡多的答案是正确的,但并不能帮助我解决问题。这是我需要为我的主人做的urls.py

from allauth.account.views import confirm_email
.....
url(r'^accounts-rest/registration/account-confirm-email/(?P<key>.+)/$', confirm_email, name='account_confirm_email'),
Run Code Online (Sandbox Code Playgroud)

确保url规范的开头以您用于allauth REST调用的任何路径开头。

当然,以上内容是使用内置视图处理确认的。