#36121: Allow customization of password_change_form in the Django admin site
-------------------------------------+-------------------------------------
     Reporter:  Mohammadreza         |                    Owner:  (none)
  Eskandari                          |
         Type:  New feature          |                   Status:  new
    Component:  contrib.admin        |                  Version:  5.1
     Severity:  Normal               |               Resolution:
     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
-------------------------------------+-------------------------------------
Description changed by Mohammadreza Eskandari:

Old 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.

New 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 have submitted a pull request which is available at
 https://github.com/django/django/pull/19081

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701948860997a-5d1b1668-88e1-4b29-8c78-368d399cc893-000000%40eu-central-1.amazonses.com.

Reply via email to