Opened 19 hours ago

Last modified 17 hours ago

#36121 assigned New feature

Allow customization of password_change_form in the Django admin site — at Initial Version

Reported by: Mohammadreza Eskandari Owned by:
Component: contrib.admin Version: 5.1
Severity: Normal Keywords: password_change, admin_site
Cc: Mohammadreza Eskandari Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (0)

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