#36121: Allow customization of password_change_form in the Django admin site
-------------------------------------+-------------------------------------
Reporter: mohammadrezaesk | Type: New
| feature
Status: new | Component:
| contrib.admin
Version: 5.1 | Severity: Normal
Keywords: password_change, | Triage Stage:
admin_site | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
The Django admin site currently provides the ability to customize the
login_form through the AdminSite.login_form attribute. However, no similar
mechanism exists to customize the password_change_form used in the admin
for password changes.
This inconsistency limits flexibility for developers who want to provide
custom logic or fields for password changes in the admin interface. For
example, a developer may want to enforce additional security checks,
integrate password strength validation, or provide a more user-friendly
design.
**Proposed Solution:
**Introduce a new attribute, AdminSite.password_change_form, which
developers can override to specify a custom form for the password change
functionality. This attribute would function similarly to
AdminSite.login_form, allowing developers to define and register a custom
form class.
**Benefits:
**\\
- Enhances consistency with existing AdminSite customization options.
- Provides more flexibility for developers working with the Django admin
site.
- Simplifies the implementation of custom password change logic.
**Example:**
{{{
from django.contrib.admin import AdminSite
from myapp.forms import CustomPasswordChangeForm
class MyAdminSite(AdminSite):
password_change_form = CustomPasswordChangeForm
}}}
**Potential Backwards Compatibility Issues:
**The proposed change should not introduce any breaking changes, as the
default behavior would remain unchanged unless password_change_form is
explicitly set.
**My Contribution:
**I am ready to submit a pull request. If the idea is accepted, I will
ensure the implementation adheres to Django's standards, including adding
documentation and tests where necessary.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36121>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.