mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #32235 -- Made ReadOnlyPasswordHashField disabled by default.
This commit is contained in:
parent
d746f28949
commit
d8dfff2ab0
4 changed files with 15 additions and 21 deletions
|
@ -1129,7 +1129,7 @@ code would be required in the app's ``admin.py`` file::
|
|||
class UserChangeForm(forms.ModelForm):
|
||||
"""A form for updating users. Includes all the fields on
|
||||
the user, but replaces the password field with admin's
|
||||
password hash display field.
|
||||
disabled password hash display field.
|
||||
"""
|
||||
password = ReadOnlyPasswordHashField()
|
||||
|
||||
|
@ -1137,12 +1137,6 @@ code would be required in the app's ``admin.py`` file::
|
|||
model = MyUser
|
||||
fields = ('email', 'password', 'date_of_birth', 'is_active', 'is_admin')
|
||||
|
||||
def clean_password(self):
|
||||
# Regardless of what the user provides, return the initial value.
|
||||
# This is done here, rather than on the field, because the
|
||||
# field does not have access to the initial value
|
||||
return self.initial["password"]
|
||||
|
||||
|
||||
class UserAdmin(BaseUserAdmin):
|
||||
# The forms to add and change user instances
|
||||
|
@ -1182,3 +1176,10 @@ Finally, specify the custom model as the default user model for your project
|
|||
using the :setting:`AUTH_USER_MODEL` setting in your ``settings.py``::
|
||||
|
||||
AUTH_USER_MODEL = 'customauth.MyUser'
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
|
||||
In older versions, ``ReadOnlyPasswordHashField`` is not
|
||||
:attr:`~django.forms.Field.disabled` by default and
|
||||
``UserChangeForm.clean_password()`` is required to return the initial
|
||||
value, whatever the user provides.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue