Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django.urls.exceptions.NoReverseMatch: Reverse for 'password_reset_reset' with arguments '('NQ:1dYOiG:BKXR_HhymHf7uYTnlDcPHioITOY',)' and keyword arguments '{}' not found. 0 pattern(s) tried: [] #60

Open
glon opened this issue Jul 21, 2017 · 2 comments

Comments

@glon
Copy link

glon commented Jul 21, 2017

hi, @brutasse

I met a problem, and could not find an answer through google or the docs, so that I've to disturb you.

Django: 1.10.1
Python: 3.5.2

When a user tries to reset password, it throws exception:

NoReverseMatch at /pwd_reset/recover/
Reverse for 'password_reset_reset' with arguments '('NQ:1dYOiG:BKXR_HhymHf7uYTnlDcPHioITOY',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Request Method:	POST
Request URL:	http://127.0.0.1:8000/pwd_reset/recover/
Django Version:	1.10.1
Exception Type:	NoReverseMatch
Exception Value:	
Reverse for 'password_reset_reset' with arguments '('NQ:1dYOiG:BKXR_HhymHf7uYTnlDcPHioITOY',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location:	/home/vagrant/.pyenv/versions/venv-3.5.2/lib/python3.5/site-packages/django/urls/resolvers.py in _reverse_with_prefix, line 392
Python Executable:	/home/vagrant/.pyenv/versions/venv-3.5.2/bin/python
Python Version:	3.5.2
Python Path:	
['/home/vagrant/codes/django_test/mysite',
 '/home/vagrant/codes/django_test/mysite',
 '/home/vagrant/.pyenv/versions/3.5.2/lib/python35.zip',
 '/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5',
 '/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/plat-linux',
 '/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/lib-dynload',
 '/home/vagrant/.pyenv/versions/venv-3.5.2/lib/python3.5/site-packages']
Server time:	Fri, 21 Jul 2017 03:34:48 +0000

Error during template rendering

In template /home/vagrant/codes/django_test/mysite/templates/password_reset/recovery_email.txt, error at line 7
Reverse for 'password_reset_reset' with arguments '('NQ:1dYOiG:BKXR_HhymHf7uYTnlDcPHioITOY',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

1	{% load i18n %}{% blocktrans %}Dear {{ username }},{% endblocktrans %}
2	
3	{% blocktrans with domain=site.domain %}You -- or someone pretending to be you -- has requested a password reset on {{ domain }}.{% endblocktrans %}
4	
5	{% trans "You can set your new password by following this link:" %}
6	
7	http{% if secure %}s{% endif %}://{{ site.domain }}{% url "password_reset_reset" token %}
8	
9	{% trans "If you don't want to reset your password, simply ignore this email and it will stay unchanged." %}
10	

The red words: {% url "password_reset_reset" token %}


codes:

settings.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'account',
    'password_reset',
]

urls.py

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^blog/', include('blog.urls', namespace='blog', app_name='blog')),
    url(r'^account/', include('account.urls', namespace='account', app_name='account')),
    url(r'^pwd_reset/', include('password_reset.urls', namespace='pwd_reset', app_name='pwd_reset')),
]

I followed the documentation and wrote the codes above in the project's root settings and urls file.

When I visited the url http://127.0.0.1:8000/pwd_reset/recover/ and submitted a username, then an exception came.

Thank you!

@glon
Copy link
Author

glon commented Jul 21, 2017

OK, I found what happened.

url(r'^pwd_reset/', include('password_reset.urls', namespace='pwd_reset', app_name='pwd_reset')),

should be

url(r'^pwd_reset/', include('password_reset.urls')),

But, what caused this question is still a little bit confused
when I use namespace and app_name, then the template is {% url "pwd_reset:password_reset_reset" token %}. Same exception again.

@fndos
Copy link

fndos commented Sep 6, 2018

I had the same problem, just use a relative URL instead {% url "pwd_reset:password_reset_reset" %} something like this:
<p><a class="forget" href="../../recover/">¿Olvidaste la contraseña?</a></p>
And in your main urls.py
url(r'^/', include('password_reset.urls')),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants