django-registration 激活用户但显示错误
我正在使用 django-registration,它以某种方式停止了应有的工作方式。我完全迷失了方向,不知道从哪里开始寻找错误。
因此,每当用户单击激活链接时,他都会获得activation.html 模板。仅当出现错误时才应该显示。
但实际上并没有错误。用户被激活并可以登录。
对此的任何想法将不胜感激。
I'm using django-registration which somehow stopped working the way it should work. I'm completely lost on this and have no idea where to start looking for the error.
So what happens is, that whenever a user clicks on the activation link, he gets the activation.html template. Which should only be shown when there was an error.
But actually there is no error. The user gets activated and can log in.
Any thoughts on this will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,你的帖子主题和实际描述是矛盾的。主题说 django-registration 总是无法激活用户,但是在你的描述中你说用户被激活并且可以登录。是哪一个?
其次,单击激活链接应始终将用户引导至 activate.html。该页面上将有一个名为
account
的变量。如果激活成功,account
将填充 User 对象,否则将为 False。First of all, the subject of your post and the actual description are conflicting. The subject says django-registration always fails to activate the user, but then in your description you say the user gets activated and can log in. Which is it?
Secondly, clicking on the activation link should always send the user to activate.html. You will have a variable called
account
on that page. If the activation was successful,account
will be populated with the User object, otherwise it will be False.0.7 和 0.8 之间有一个很大的区别:
在 0.7 中:
当用户尝试注册时会显示 registration/activate.html
激活他/她的帐户。
在 0.8
registration/activate.html
帐户激活失败时使用。
There is a big difference between 0.7 and 0.8:
in 0.7:
registration/activate.html is displayed when a user attempts to
activate his/her account.
in 0.8
registration/activate.html
Used if account activation fails.
调试registration.views.activate显示:如果未设置
success_url
,调用
backend.post_activation_redirect
方法。如果您使用默认后端,则会返回一个空上下文,不包含在模板中查询的帐户变量。解决方案可能是覆盖默认后端。
唯一的问题是您无法通过重定向将任何对象传递给视图。因此,您无法将帐户传递到模板上下文。如果愿意,您可以使用 get params 来完成。
我决定只更改激活模板并删除条件。
Debugging registration.views.activate showed: if the
success_url
isn't set,the
backend.post_activation_redirect
method is called. If you're using the default backend, that returns an empty context without the account variable which is queried in the template.The solution could be to overwrite the default backend.
The only problem is that you cannot pass any objects to views over a redirect. Hence, you cannot pass the account to the template context. You could do it with get params if wanted to.
I decided to just change the activation template and remove the condition.