mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +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:
parent
11c5c3b801
commit
fa4b5c1b93
4 changed files with 33 additions and 0 deletions
|
@ -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
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue