mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.10.x] Fixed #26988 -- Improved/clarified User.is_authenticated/anonymous compatibility.
Thanks marktranchant for the report and review.
Backport of 54afa960d1 from master
This commit is contained in:
@@ -11,3 +11,6 @@ Bugfixes
|
||||
|
||||
* Fixed a crash in MySQL connections where ``SELECT @@SQL_AUTO_IS_NULL``
|
||||
doesn't return a result (:ticket:`26991`).
|
||||
|
||||
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
|
||||
compared using ``==`` and ``!=`` (:ticket:`26988`).
|
||||
|
||||
@@ -1061,6 +1061,14 @@ method, e.g.::
|
||||
If you override these methods in a custom user model, you must change them to
|
||||
properties or attributes.
|
||||
|
||||
Django uses a ``CallableBool`` object to allow these attributes to work as both
|
||||
a property and a method. Thus, until the deprecation period ends, you cannot
|
||||
compare these properties using the ``is`` operator. That is, the following
|
||||
won't work::
|
||||
|
||||
if request.user.is_authenticated is True:
|
||||
...
|
||||
|
||||
Custom manager classes available through ``prefetch_related`` must define a ``_apply_rel_filters()`` method
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user