summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorlevental <levental@fh-brandenburg.de>2016-09-19 14:55:18 +0200
committerTim Graham <timograham@gmail.com>2016-09-27 11:59:00 -0400
commit617e36dc1ede2a311dfd03f18432b31cbfe4c0f7 (patch)
tree38fd43fc044ff923321b444c292686798dfb17bd /docs
parentf7e91cac689b28fc32ca52cdeac258ec0d58b4fc (diff)
Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.11.txt5
-rw-r--r--docs/topics/auth/customizing.txt23
2 files changed, 25 insertions, 3 deletions
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index ded12408b9..411c6fb3ab 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -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`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt
index 068671c259..f3b53f17f5 100644
--- a/docs/topics/auth/customizing.txt
+++ b/docs/topics/auth/customizing.txt
@@ -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