diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/2.1.txt | 4 | ||||
| -rw-r--r-- | docs/topics/auth/customizing.txt | 32 | ||||
| -rw-r--r-- | docs/topics/auth/default.txt | 9 |
3 files changed, 21 insertions, 24 deletions
diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt index 3c9fad8ca5..f349d1ed9a 100644 --- a/docs/releases/2.1.txt +++ b/docs/releases/2.1.txt @@ -48,6 +48,10 @@ Minor features * :djadmin:`createsuperuser` now gives a prompt to allow bypassing the :setting:`AUTH_PASSWORD_VALIDATORS` checks. +* :class:`~django.contrib.auth.forms.UserCreationForm` and + :class:`~django.contrib.auth.forms.UserChangeForm` no longer need to be + rewritten for a custom user model. + :mod:`django.contrib.contenttypes` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index ce518b41be..97fac352ac 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -820,11 +820,20 @@ are working with. The following forms are compatible with any subclass of :class:`~django.contrib.auth.models.AbstractBaseUser`: -* :class:`~django.contrib.auth.forms.AuthenticationForm`: Uses the username - field specified by :attr:`~models.CustomUser.USERNAME_FIELD`. +* :class:`~django.contrib.auth.forms.AuthenticationForm` * :class:`~django.contrib.auth.forms.SetPasswordForm` * :class:`~django.contrib.auth.forms.PasswordChangeForm` * :class:`~django.contrib.auth.forms.AdminPasswordChangeForm` +* :class:`~django.contrib.auth.forms.UserCreationForm` +* :class:`~django.contrib.auth.forms.UserChangeForm` + +The forms that handle a username use the username field specified by +:attr:`~models.CustomUser.USERNAME_FIELD`. + +.. versionchanged:: 2.1 + + In older versions, ``UserCreationForm`` and ``UserChangeForm`` need to be + rewritten to work with custom user models. The following forms make assumptions about the user model and can be used as-is if those assumptions are met: @@ -835,25 +844,6 @@ if those assumptions are met: default) that can be used to identify the user and a boolean field named ``is_active`` to prevent password resets for inactive users. -Finally, the following forms are tied to -:class:`~django.contrib.auth.models.User` and need to be rewritten or extended -to work with a custom user model: - -* :class:`~django.contrib.auth.forms.UserCreationForm` -* :class:`~django.contrib.auth.forms.UserChangeForm` - -If your custom user model is a simple subclass of ``AbstractUser``, then you -can extend these forms in this manner:: - - from django.contrib.auth.forms import UserCreationForm - from myapp.models import CustomUser - - class CustomUserCreationForm(UserCreationForm): - - class Meta(UserCreationForm.Meta): - model = CustomUser - fields = UserCreationForm.Meta.fields + ('custom_field',) - Custom users and :mod:`django.contrib.admin` -------------------------------------------- diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt index a4ba59b02f..3e8a63c25f 100644 --- a/docs/topics/auth/default.txt +++ b/docs/topics/auth/default.txt @@ -1486,9 +1486,12 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`: A :class:`~django.forms.ModelForm` for creating a new user. - It has three fields: ``username`` (from the user model), ``password1``, - and ``password2``. It verifies that ``password1`` and ``password2`` match, - validates the password using + It has three fields: one named after the + :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` from the + user model, and ``password1`` and ``password2``. + + It verifies that ``password1`` and ``password2`` match, validates the + password using :func:`~django.contrib.auth.password_validation.validate_password`, and sets the user's password using :meth:`~django.contrib.auth.models.User.set_password()`. |
