Django Password Reset Error: The URL path must contain 'uidb64' and 'token' parameters

I was trying to implement password reset with email in django. These are my views:

class UserPasswordResetView(PasswordResetView):
    template_name = "accounts/password_reset_form.html"
    email_template_name = "accounts/password_reset_email.html"
    success_url = reverse_lazy("accounts:password_reset_done")


class UserPasswordResetDoneView(PasswordResetDoneView):
    template_name = "accounts/password_reset_done.html"


class UserPasswordResetConfirmView(PasswordResetConfirmView):
    template_name = "accounts/password_reset_confirm.html"
    success_url = reverse_lazy("accounts:password_reset_complete")


class UserPasswordResetCompleteView(PasswordResetCompleteView):
    template_name = "accounts/password_reset_complete.html"

urls.py:

path("reset/", UserPasswordResetView.as_view(), name="password_reset"),
path(
    "reset/done/", UserPasswordResetDoneView.as_view(), name="password_reset_done"
),
path(
    "confirm/<uidb64>/<token>/",
    UserPasswordResetConfirmView.as_view(),
    name="password_reset_confirm",
),
path(
    "confirm/complete/",
    UserPasswordResetConfirmView.as_view(),
    name="password_reset_complete",
),

Everything goes well to password confirm phase. But after I submit the form, instead of showing the password_reset_complete.html, it shows this error:

ImproperlyConfigured at /accounts/confirm/complete/
The URL path must contain 'uidb64' and 'token' parameters.

It says it's missing those parameters in password_reset_complete url. So I tried adding them to the url:

path(
    "confirm/complete/<uidb64>/<token>/",
    UserPasswordResetConfirmView.as_view(),
    name="password_reset_complete",
),

And it shows this new error:

NoReverseMatch at /accounts/confirm/MQ/set-password/
Reverse for 'password_reset_complete' with no arguments not found. 1 pattern(s) tried: ['accounts/confirm/complete/(?P<uidb64>[^/]+)/(?P<token>[^/]+)/\\Z']

Despite raising these errors, password is actually reset. The only problem is with displaying password reset complete template.

Back to Top