1
0
mirror of https://github.com/django/django.git synced 2025-03-15 20:00:46 +00:00

[1.11.x] Fixed #28420 -- Doc'd 'is' comparison restriction for User.is_authenticated/anonymous.

This commit is contained in:
Tobias Schulmann 2017-07-23 08:43:23 +12:00 committed by Tim Graham
parent 801b6fb32e
commit aef117eb2e

View File

@ -145,6 +145,15 @@ Attributes
In older versions, this was a method. Backwards-compatibility
support for using it as a method will be removed in Django 2.0.
.. admonition:: Don't use the ``is`` operator for comparisons!
To allow the ``is_authenticated`` and ``is_anonymous`` attributes
to also work as methods, the attributes are ``CallableBool``
objects. Thus, until the deprecation period ends in Django 2.0, you
can't compare these properties using the ``is`` operator. That is,
``request.user.is_authenticated is True`` always evaluate to
``False``.
.. attribute:: is_anonymous
Read-only attribute which is always ``False``. This is a way of