diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index a5de5bf650..87f916dae4 100644
|
a
|
b
|
class UserCreationForm(forms.ModelForm):
|
| 83 | 83 | ) |
| 84 | 84 | |
| 85 | 85 | class Meta: |
| 86 | | model = User |
| | 86 | model = UserModel |
| 87 | 87 | fields = ("username",) |
| 88 | 88 | field_classes = {'username': UsernameField} |
| 89 | 89 | |
| … |
… |
class UserChangeForm(forms.ModelForm):
|
| 132 | 132 | ) |
| 133 | 133 | |
| 134 | 134 | class Meta: |
| 135 | | model = User |
| | 135 | model = UserModel |
| 136 | 136 | fields = '__all__' |
| 137 | 137 | field_classes = {'username': UsernameField} |
| 138 | 138 | |
diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt
index 84f0782eb5..382a480717 100644
|
a
|
b
|
The following forms are compatible with any subclass of
|
| 840 | 840 | * :class:`~django.contrib.auth.forms.SetPasswordForm` |
| 841 | 841 | * :class:`~django.contrib.auth.forms.PasswordChangeForm` |
| 842 | 842 | * :class:`~django.contrib.auth.forms.AdminPasswordChangeForm` |
| | 843 | * :class:`~django.contrib.auth.forms.UserCreationForm` |
| | 844 | * :class:`~django.contrib.auth.forms.UserChangeForm` |
| | 845 | |
| 843 | 846 | |
| 844 | 847 | The following forms make assumptions about the user model and can be used as-is |
| 845 | 848 | if those assumptions are met: |
| … |
… |
if those assumptions are met:
|
| 850 | 853 | default) that can be used to identify the user and a boolean field named |
| 851 | 854 | ``is_active`` to prevent password resets for inactive users. |
| 852 | 855 | |
| 853 | | Finally, the following forms are tied to |
| 854 | | :class:`~django.contrib.auth.models.User` and need to be rewritten or extended |
| 855 | | to work with a custom user model: |
| 856 | | |
| 857 | | * :class:`~django.contrib.auth.forms.UserCreationForm` |
| 858 | | * :class:`~django.contrib.auth.forms.UserChangeForm` |
| 859 | | |
| 860 | | If your custom user model is a simple subclass of ``AbstractUser``, then you |
| 861 | | can extend these forms in this manner:: |
| 862 | | |
| 863 | | from django.contrib.auth.forms import UserCreationForm |
| 864 | | from myapp.models import CustomUser |
| 865 | | |
| 866 | | class CustomUserCreationForm(UserCreationForm): |
| 867 | | |
| 868 | | class Meta(UserCreationForm.Meta): |
| 869 | | model = CustomUser |
| 870 | | fields = UserCreationForm.Meta.fields + ('custom_field',) |
| 871 | 856 | |
| 872 | 857 | Custom users and :mod:`django.contrib.admin` |
| 873 | 858 | -------------------------------------------- |