Difficulty customizing django allauth password recovery page

I’m using Django allauth and I want to subscribe to recover password pages. For this, I created a new views/class “ResetPassword” which inherits “PasswordResetView”, and “ResetPasswordKey” which inherits “PasswordResetFromKeyView”.

class ResetPassword(PasswordResetView):
    template_name = "account/password_reset.html"

class ResetPasswordKey(PasswordResetFromKeyView):
    template_name = "account/password_reset_key.html" 

I defined the urls and custom forms that I want to use in “settings.py”.

urlpatterns = [
...
    # Accounts
    path("accounts/", include("allauth.urls")),
    path("accounts/", include("allauth.socialaccount.urls")),
    path("accounts/login/", Login.as_view(), name="login"),
    path("accounts/signup/", SignUp.as_view(), name="signup"),
    path("accounts/reset/password/", ResetPassword.as_view(), name="reset_password"),
    path("accounts/reset/password/key/<uidb36>/<key>/", ResetPasswordKey.as_view(), name="reset_password_key"),
]
ACCOUNT_FORMS = {
    "login": "subscriptions.forms.CustomLoginForm",
    "signup": "subscriptions.forms.CustomSignupForm",
    "reset_password": "subscriptions.forms.CustomResetPasswordForm",
    "reset_password_key": "subscriptions.forms.CustomResetPasswordKeyForm",
}

I receive this url in the email: “http://localhost:8000/accounts/password/reset/key/2-c87r5r-f01fef92a2b053a44b60a8c74b1fc3b2/
but when I try to open it I get the following error:

# NoReverseMatch at /accounts/password/reset/key/2-set-password/

Reverse for 'reset_password_key' with no arguments not found. 1 pattern(s) tried: ['accounts/reset/password/key/(?P<uidb36>[^/]+)/(?P<key>[^/]+)/\\Z']

I imagine that the way I am defining the url of the ResetPasswordKey class is wrong. ResetPassword works normally.

password_reset_from_key.html:

<div id="login">
        <div id="formLogin">
            <form method="post" action="{% url 'reset_password_key' %}">
                {% csrf_token %}
            <img src="{% static "account/imgs/logo.png" %}" alt="logo">

            <div class="inputContainer">
                {{ form.password1 }}
                <!--<input type="email" class="inputLogin">-->
                <label class="labelLogin">Nova Senha</label>
            </div>

            <div class="inputContainer2">
                {{ form.password2 }}
                <!--<input type="password" class="inputSenha">-->
                <label class="labelPassword">Nova Senha (novamente)</label>
            </div>

            {% if form.errors %}
            <p style="color:red;font-size:7pt;">O E-mail e/ou senha especificados não estão corretos.</p>
            {% endif %}
            <input type="submit" class="submitButton" value="Login">
            </form>
        </div>
    </div>

thank you for your attention.

Welcome @luxasz7 !

I see at least two things wrong here.

First, you’re supplying the url segment names in the wrong order. You have:

but the url you have generated is:

Additionally, that url requires two parameters be supplied after the url segment “key” - uidb36 and key, but you are only supplying one parameter after the word “key”.

Check your code that is generating the url for the email.

Thank you very much, I will try to make the modifications and I’ll let you know!