Opened 3 months ago

Closed 3 months ago

#31593 closed Cleanup/optimization (invalid)

Replace hardcoded path to PasswordChangeView in UserChangeForm with reverse of its URL

Reported by: Denis Owned by: Denis
Component: Forms Version: 3.0
Severity: Normal Keywords: user, password, form, UserChangeForm
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


I'm using built-in forms for authentication.
Created CustomUser with CustomUserCreationForm and CustomUserChangeForm.
CustomUserChangeForm is based on UserChangeForm.

If password is get successfully help_text is supplied with '../password/' path:

help_text=_(...but you can change the password using <a href="{}">this form</a>.),
if password:
    password.help_text = password.help_text.format('../password/')

But aimed form has password_change URL in auth/

path('password_change/', views.PasswordChangeView.as_view(), name='password_change'),

And there is no easy way to substitute it (I mean it's a hardcoded string)

Change History (2)

comment:1 Changed 3 months ago by Denis

Owner: changed from nobody to Denis
Status: newassigned

It's my first ticket and fix.

I have fixed it locally and it works fine:

from django.urls import reverse
password.help_text = password.help_text.format(reverse('password_change'))

Is it trivial or requires a patch?

comment:2 Changed 3 months ago by Denis

Resolution: invalid
Status: assignedclosed

It's an admin's form: "A form used in the admin interface to change a user’s information and permissions"
And 'password/' path works fine there

Note: See TracTickets for help on using tickets.
Back to Top