diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 9279c52..e011d47 100644
|
a
|
b
|
class ReadOnlyPasswordHashField(forms.Field):
|
| 52 | 52 | kwargs.setdefault("required", False) |
| 53 | 53 | super(ReadOnlyPasswordHashField, self).__init__(*args, **kwargs) |
| 54 | 54 | |
| | 55 | def bound_data(self, data, initial): |
| | 56 | # Always return initial because the widget doesn't |
| | 57 | # render an input field. |
| | 58 | return initial |
| | 59 | |
| 55 | 60 | |
| 56 | 61 | class UserCreationForm(forms.ModelForm): |
| 57 | 62 | """ |
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index f3eb242..87fcfc8 100644
|
a
|
b
|
class UserChangeFormTest(TestCase):
|
| 282 | 282 | self.assertTrue(form.is_valid()) |
| 283 | 283 | self.assertEqual(form.cleaned_data['password'], 'sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161') |
| 284 | 284 | |
| | 285 | def test_bug_19349_bound_password_field(self): |
| | 286 | user = User.objects.get(username='testclient') |
| | 287 | form = UserChangeForm(data={}, instance=user) |
| | 288 | # When rendering the bound password field, |
| | 289 | # ReadOnlyPasswordHashWidget needs the initial |
| | 290 | # value to render correctly |
| | 291 | self.assertEqual(form.initial['password'], form['password'].value()) |
| | 292 | |
| 285 | 293 | |
| 286 | 294 | @skipIfCustomUser |
| 287 | 295 | @override_settings(USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) |