gpt4 book ai didi

python Django 重置密码 URL NoReverseMatch

转载 作者:太空宇宙 更新时间:2023-11-03 17:59:45 24 4
gpt4 key购买 nike

我在 Django 密码重置方面遇到问题。这是我的 urls.py:

(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', {'template_name':'registration/password_reset_done.html'}),
(r'^resetpassword/$', 'django.contrib.auth.views.password_reset'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),

当我转到resetpassword时,我得到了

NoReverseMatch at /resetpassword/
Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

如果需要的话,这是我的回溯:

Request Method: GET
Request URL: http://127.0.0.1:8000/resetpassword/

Django Version: 1.7.1
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'dailyresults',
'trainingresults',
'athlete',
'easy_pdf')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "D:\Programy\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\handlers\base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\Programy\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\utils\decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "D:\Programy\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\contrib\auth\views.py" in password_reset
146. post_reset_redirect = reverse('password_reset_done')
File "D:\Programy\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\urlresolvers.py" in reverse
551. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "D:\Programy\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\urlresolvers.py" in _reverse_with_prefix
468. (lookup_view_s, args, kwargs, len(patterns), patterns))

Exception Type: NoReverseMatch at /resetpassword/
Exception Value: Reverse for 'password_reset_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

任何帮助将不胜感激。

最佳答案

使用url函数而不是简单的元组并设置url的name:

from django.conf.urls import url
...
url(r'^resetpassword/passwordsent/$',
'django.contrib.auth.views.password_reset_done',
{'template_name':'registration/password_reset_done.html'},
name="password_reset_done"),

关于python Django 重置密码 URL NoReverseMatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27899407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com