0
votes

I'm using django-registration in my Django application with HMAC workflow. An email is sent with the activation link to the user after registration.

I'm using the versions bellow:

Django==1.11.1
django-registration==2.3

I saw here that there are two different views (function ou class) that could have being used. I put a breakpoint in the auth_urls.py and saw that in my application the registration.auth_urls_classes that are being used.

I've created a link to go to my reset password page:

<a class="g-font-size-12" href="{% url 'auth_password_reset' %}">Esqueceu a senha?</a>

This link sends to the template password_reset_form.html, it is in the image bellow:

{% extends "base.html" %}
{% load i18n %}

{% block content %}
<div class="row justify-content-center g-py-180">
    <div class="col-sm-10 col-md-9 col-lg-4">
        <header class="text-center g-mb-30">
            <h2 class="h2 g-color-black g-font-weight-600"> Resete sua senha </h2>
        </header>
        <form method="post" action="{% url 'auth_password_reset' %}">
            <h1 class="h5 g-font-weight-300">Forneça seu endereço de email e nós enviaremos para você um link para alterar sua senha.</h1>


            {% csrf_token %}

            {% for field in form %}
                {% if field.name ==  'email' %}
                    <div class="mb-4 mt-4">
                      <input class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4
                         g-brd-primary--hover rounded g-py-15 g-px-15" type="email" required
                         placeholder="[email protected]" name="{{ field.html_name }}" id="{{ field.auto_id }}">
                    </div>
                {% endif %}
            {% endfor %}
            <button class="g-min-width-100x btn btn-md u-btn-primary rounded g-py-13 g-px-25" type="submit" value="Submit">Enviar email de redefinição de senha</button>
        </form>
    </div>
</div>
{% endblock %}

After typing the email address and send the form, the email is sent correctly (email arrived to me), but the error bellow occurrs:

Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/accounts/password/reset/auth_password_reset_done

My urls are defined as bellow:

urlpatterns = [
    url(r'^$', TemplateView.as_view(template_name='index.html'), name='home'),

    #authentication
    url(r'^accounts/', include('registration.backends.hmac.urls')),

    url(r'^profile/', include('pxgbr2.account_settings.urls', namespace='profile')),
    url(r'^admin/', admin.site.urls),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, 
document_root=settings.MEDIA_ROOT)

Note that the name of the success url (auth_password_reset_done') was "appended" in the link, instead of being replaced by the pattern. I couldn't figure out why, though.

1
Don't post screenshots of text.Daniel Roseman

1 Answers

1
votes

You appear to have hit this issue. There is a fix pull request #111 that you could try or it might be simpler to include Django's auth URLs yourself:

url('^accounts/', include('django.contrib.auth.urls')),
url('^accounts/', include('registration.backends.hmac.urls')),

The registration.auth_urls will be removed in django-registration 3.0, so including the auth urls separately is the best approach for the future.