mirror of
https://github.com/django/django.git
synced 2025-07-23 13:15:32 +00:00
Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.
This commit is contained in:
parent
f7e91cac68
commit
617e36dc1e
8 changed files with 86 additions and 7 deletions
|
@ -120,6 +120,11 @@ Minor features
|
|||
* The :func:`~django.contrib.auth.signals.user_login_failed` signal now
|
||||
receives a ``request`` argument.
|
||||
|
||||
* :class:`~django.contrib.auth.forms.PasswordResetForm` supports custom user
|
||||
models that use an email field named something other than ``'email'``.
|
||||
Set :attr:`CustomUser.EMAIL_FIELD
|
||||
<django.contrib.auth.models.CustomUser.EMAIL_FIELD>` to the name of the field.
|
||||
|
||||
:mod:`django.contrib.contenttypes`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -544,6 +544,14 @@ password resets. You must then provide some key implementation details:
|
|||
value (the :attr:`~django.db.models.Field.primary_key` by default) of an
|
||||
existing instance.
|
||||
|
||||
.. attribute:: EMAIL_FIELD
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
A string describing the name of the email field on the ``User`` model.
|
||||
This value is returned by
|
||||
:meth:`~models.AbstractBaseUser.get_email_field_name`.
|
||||
|
||||
.. attribute:: REQUIRED_FIELDS
|
||||
|
||||
A list of the field names that will be prompted for when creating a
|
||||
|
@ -623,6 +631,14 @@ The following attributes and methods are available on any subclass of
|
|||
override this method, be sure to call ``super()`` to retain the
|
||||
normalization.
|
||||
|
||||
.. classmethod:: get_email_field_name()
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
Returns the name of the email field specified by the
|
||||
:attr:`~models.CustomUser.EMAIL_FIELD` attribute. Defaults to
|
||||
``'email'`` if ``EMAIL_FIELD`` isn't specified.
|
||||
|
||||
.. classmethod:: normalize_username(username)
|
||||
|
||||
.. versionadded:: 1.10
|
||||
|
@ -807,9 +823,10 @@ The following forms make assumptions about the user model and can be used as-is
|
|||
if those assumptions are met:
|
||||
|
||||
* :class:`~django.contrib.auth.forms.PasswordResetForm`: Assumes that the user
|
||||
model has a field named ``email`` that can be used to identify the user and a
|
||||
boolean field named ``is_active`` to prevent password resets for inactive
|
||||
users.
|
||||
model has a field that stores the user's email address with the name returned
|
||||
by :meth:`~models.AbstractBaseUser.get_email_field_name` (``email`` by
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue