1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed #26381 -- Made UserCreationForm reusable with custom user models that define USERNAME_FIELD.

This commit is contained in:
Berker Peksag
2016-03-20 12:24:51 +02:00
committed by Tim Graham
parent 2b31f14d89
commit efa9539787
2 changed files with 17 additions and 2 deletions

View File

@@ -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")