mirror of
https://github.com/django/django.git
synced 2025-09-18 00:10:22 +00:00
Fixed #19872
Made cached_property to behave as property when accessed via class.
This commit is contained in:
parent
83ecb7b145
commit
b88abd6840
2 changed files with 31 additions and 2 deletions
|
@ -39,7 +39,9 @@ class cached_property(object):
|
|||
def __init__(self, func):
|
||||
self.func = func
|
||||
|
||||
def __get__(self, instance, type):
|
||||
def __get__(self, instance, type=None):
|
||||
if instance is None:
|
||||
return self
|
||||
res = instance.__dict__[self.func.__name__] = self.func(instance)
|
||||
return res
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue