mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #29478 -- Added support for mangled names to cached_property.
Co-Authored-By: Sergey Fedoseev <fedoseev.sergey@gmail.com>
This commit is contained in:
committed by
Tim Graham
parent
80ba7a881f
commit
0607699902
@@ -351,6 +351,35 @@ To simplify a few parts of Django's database handling, `sqlparse
|
||||
<https://pypi.org/project/sqlparse/>`_ is now a required dependency. It's
|
||||
automatically installed along with Django.
|
||||
|
||||
``cached_property`` aliases
|
||||
---------------------------
|
||||
|
||||
In usage like::
|
||||
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
class A:
|
||||
|
||||
@cached_property
|
||||
def base(self):
|
||||
return ...
|
||||
|
||||
alias = base
|
||||
|
||||
``alias`` is not cached. Such usage now raises ``TypeError: Cannot assign the
|
||||
same cached_property to two different names ('base' and 'alias').`` on Python
|
||||
3.6 and later.
|
||||
|
||||
Use this instead::
|
||||
|
||||
import operator
|
||||
|
||||
class A:
|
||||
|
||||
...
|
||||
|
||||
alias = property(operator.attrgetter('base'))
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user