[Django] #31593: Replace hardcoded path to PasswordChangeView in UserChangeForm with reverse of its URL

5 views
Skip to first unread message

Django

unread,
May 15, 2020, 12:46:47 PM5/15/20
to django-...@googlegroups.com
#31593: Replace hardcoded path to PasswordChangeView in UserChangeForm with reverse
of its URL
-------------------------------------+-------------------------------------
Reporter: Denis | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: 3.0
Severity: Normal | Keywords: user, password,
Triage Stage: | form, UserChangeForm
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
I'm using built-in forms for authentication.
Created {{{CustomUser}}} with
[https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#custom-
users-and-the-built-in-auth-forms CustomUserCreationForm] and
CustomUserChangeForm.
CustomUserChangeForm is based on
[https://github.com/django/django/blob/stable/3.0.x/django/contrib/auth/forms.py#L141
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
[https://github.com/django/django/blob/stable/3.0.x/django/contrib/auth/urls.py#L13
auth/urls.py]:
{{{
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)

--
Ticket URL: <https://code.djangoproject.com/ticket/31593>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 15, 2020, 12:51:50 PM5/15/20
to django-...@googlegroups.com
#31593: Replace hardcoded path to PasswordChangeView in UserChangeForm with reverse
of its URL
-------------------------------------+-------------------------------------
Reporter: Denis | Owner: Denis
Type: | Status: assigned

Cleanup/optimization |
Component: Forms | Version: 3.0
Severity: Normal | Resolution:

Keywords: user, password, | Triage Stage:
form, UserChangeForm | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Denis):

* owner: nobody => Denis
* status: new => assigned


Comment:

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?

--
Ticket URL: <https://code.djangoproject.com/ticket/31593#comment:1>

Reply all
Reply to author
Forward
0 new messages