noReverseMatch on password_Reset_confirm [英] NoReverseMatch on password_Reset_confirm

查看:455
本文介绍了noReverseMatch on password_Reset_confirm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



url:

 (r'^ password_reset / $','django.contrib.auth.views.password_reset'),
(r'^ password_reset_done / $','django.contrib.auth.views.password_reset_done') ,
(r'^ password_reset_confirm /(?P

password_reset_email.html / p>

  {%从未来添加网址%} 
有人要求重新设置电子邮件密码{{email}}。按照以下链接:
{{protocol}}:// {{domain}} {%url'password_reset_confirm'uidb36 = uid token = token%}

但是,在提交我的电子邮件重置密码后,我收到以下错误消息:


NoReverseMatch at / password_reset / Reverse for
'password_reset_confirm'with arguments'()'and keyword arguments
'{'uidb36':'1','token':'38d-b5ec0b2a2321f522f954 '}'没有找到。


我以为自从使用了一个视图中的构建,我不必关心任何事情其他?



感谢您的建议,



更新:



使用完整路径后,似乎可以正常工作。然而,它发送两个电子邮件:每个都有一个不同的链接。这是为什么?我在哪里设置{{domain}}?感谢

 按照以下链接:
http://example.com/password_reset_confirm/1-38d-b5ec0b2a2321f522f954/

按照以下链接:
http://example.com/password_reset_confirm/2-38d-18482e1f129c84b9c2bc/

更新2



我想出来了以防万一有人遇到这个问题。您需要将您的域名设置为应用程序的站点:



在管理员或django控制台中:

 >>> my_site = Site.objects.get(pk = 1)
>>> my_site.domain ='somedomain.com'
>>> my_site.name ='Some Domain'
>>> my_site.save()

另一个为什么在重置它时可以收到两封​​电子邮件的问题是因为您可以将多个用户名与相同的电子邮件地址相关联。它很傻这是下一件我要解决的问题。

解决方案

使用 url 模板标签,您需要指定视图而不是url本身。由于您在URLConf中使用'django.contrib.auth.views.password_reset_confirm',您应该使用它:

  {%url'django.contrib.auth.views.password_reset_confirm'...%} 

更多关于Django的 url 模板标签ref / templates / builtins /?from = olddocs#urlrel =nofollow>内置的模板标签和过滤器文档。


I have a problem getting password_Reset_confirm bit working.

url:

(r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
(r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done'),
(r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),

password_reset_email.html, which includes this:

{% load url from future %}
Someone asked for password reset for email {{ email }}. Follow the link below:
{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb36=uid token=token %}

But then after submitting my email for reseting the password, I get this error message shown:

NoReverseMatch at /password_reset/ Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{'uidb36': '1', 'token': '38d-b5ec0b2a2321f522f954'}' not found.

I thought since this was using a build in view, I wouldn't have to take care on anything else?

Thanks for advice,

Update:

After using the full path, it seems to work. However it sends two emails out: and each has a different link. Why is that? And where do I set the {{ domain }}? Thanks

Follow the link below:
http://example.com/password_reset_confirm/1-38d-b5ec0b2a2321f522f954/

Follow the link below:
http://example.com/password_reset_confirm/2-38d-18482e1f129c84b9c2bc/

Update 2

I figured it out. Just in case someone else has this problem. You need to set your domain name as the Site for your application:

In Admin or django console:

>>> my_site = Site.objects.get(pk=1)
>>> my_site.domain = 'somedomain.com'
>>> my_site.name = 'Some Domain'
>>> my_site.save()

The other problem why you could get two emails when resetting it, is because that you can have multiple usernames associated with the same email address. Its pretty silly. This is the next thing I have to tackle down.

解决方案

When using the url template tag, you need to specify the view and not the url itself. Since you are using 'django.contrib.auth.views.password_reset_confirm' in your URLConf you should use it like this:

{% url 'django.contrib.auth.views.password_reset_confirm' ... %}

More on the url template tag on Django's Built-in template tags and filters documentation.

这篇关于noReverseMatch on password_Reset_confirm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆