diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2016-03-20 12:24:51 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-03-21 12:32:42 -0400 |
| commit | efa9539787dbdd06cd2169023edcf7db3e2ff0c4 (patch) | |
| tree | 73f9bc71e4bf30d031b8fb2393661ee45f30697d /django | |
| parent | 2b31f14d89cb144fad10389824828e90fd1a2dcc (diff) | |
Fixed #26381 -- Made UserCreationForm reusable with custom user models that define USERNAME_FIELD.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/forms.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 4485e1fb14..171fa1fb41 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -82,7 +82,7 @@ class UserCreationForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(UserCreationForm, self).__init__(*args, **kwargs) - self.fields['username'].widget.attrs.update({'autofocus': ''}) + self.fields[self._meta.model.USERNAME_FIELD].widget.attrs.update({'autofocus': ''}) def clean_password2(self): password1 = self.cleaned_data.get("password1") |
