NoReverseMatch at /resetpassword/ in Django
Question: I´m getting this error during Reset Password. I have a login page whith the
link to reset forgotten password, it shows correctly the templates, but if I
write the mail to send the reset link, it shows this error:

**localhost/resesetpassword**

    
    
    NoReverseMatch at /resetpassword/
    Reverse for 'password_reset_confirm' with arguments '()' and keyword      arguments '{'token': '42e-71994a9bf9d36c22eb95', 'uidb64': b'MQ'}' not found. 0   pattern(s) tried: []
    Request Method: POST
    Request URL:    http://localhost/resetpassword/
    Django Version: 1.8.2
    Exception Type: NoReverseMatch
    Exception Value:    
    Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments '{'token': '42e-71994a9bf9d36c22eb95', 'uidb64': b'MQ'}' not found. 0 pattern(s) tried: []
    Exception Location: C:\Python34\lib\site-   packages\django\core\urlresolvers.py in _reverse_with_prefix, line 496
    Python Executable:  C:\Python34\python.exe
    Python Version: 3.4.3
    Python Path:    
    ['c:\\labsoft',
    'C:\\Python34\\lib\\site-packages\\psycopg2-2.6-py3.4-win-amd64.egg',
    'C:\\Windows\\SYSTEM32\\python34.zip',
    'C:\\Python34\\DLLs',
    'C:\\Python34\\lib',
    'C:\\Python34',
    'C:\\Python34\\lib\\site-packages']
     Server time:   Dom, 7 Jun 2015 21:46:55 -0500
    

**Error during template rendering**

    
    
         In template C:\Python34\lib\site-  packages\django\contrib\admin\templates\registration\password_reset_email.html, error at line 6
    
    
    1   {% load i18n %}{% autoescape off %}
    2   {% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
    3   
    4   {% trans "Please go to the following page and choose a new password:" %}
    5   {% block reset_link %}
    6   
      {{ protocol }}://{{ domain }}
      {% url 'password_reset_confirm' uidb64=uid token=token %}
    
    
    
    7   {% endblock %}
    8   {% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
    9   
    10  {% trans "Thanks for using our site!" %}
    11  
    12  {% blocktrans %}The {{ site_name }} team{% endblocktrans %}
    13  
    14  {% endautoescape %}
    15  
    

**It shows this code in red:**

    
    
    {{ protocol }}://{{ domain }}
    {% url 'password_reset_confirm' uidb64=uid token=token %}
    

**I think the error can be the protocol and domain parameters, but I don't
know how fix it. Thanks a lot!!!**

**urls.py**

    
    
    from django.conf.urls import patterns, url
    from .views import Buscar_view
    
    urlpatterns = patterns('melomanos.views',
                       url(r'^$','trabajos_all_view',name='url_index'),
                        url(r'^register/$','register_view',name='vista_registro'),
                       url(r'^login/$','login_view',name='vista_login'),
                       url(r'^logout/$','logout_view',name='vista_logout'),
                       url(r'^perfil/$','registro_view',name='vista_perfil'),
                       url(r'^publicar/$','trabajomusical_view', name='vista_publicar'),
                       url(r'^trabajos/$','trabajos_view',name='vista_trabajos'),
                       url(r'^trabajo/(?P<id_trabajo>.*)/$','solo_trabajo_view', name='vista_trabajo'),
                       url(r'^buscar/$',Buscar_view.as_view(),name='vista_buscar'),
                       )
    
     urlpatterns += patterns('',
                       url(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
                       url(r'^resetpassword/$', 'django.contrib.auth.views.password_reset', name="reset_password"),
                       url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>,+)/$', 'django.contrib.auth.views.password_reset_confirm'),
                       url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete',{'template_name' : 'registration/password_reset.html',  'post_reset_redirect': '/logout/' }),
                       )
    


Answer: Actually your regex for the token parameter is matching a single or multiples
commas.

You can use `<token>.+` for match any character.

Also your pattern is looking for a `-` between the `uidb64` and `token`, and
this line

    
    
    {% url 'password_reset_confirm' uidb64=uid token=token %}
    

is passing both parameters without the `-`.

You need just to alter the url line as folow:

    
    
    url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
    

