From 702f574461693efe0ea951254e2dcce7edb9a30f Mon Sep 17 00:00:00 2001 From: Vladislav Poluhin Date: Wed, 24 Apr 2013 16:04:04 +0800 Subject: Fix tests for Django 1.3 --- debug_toolbar/utils/functional.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 debug_toolbar/utils/functional.py (limited to 'debug_toolbar/utils/functional.py') diff --git a/debug_toolbar/utils/functional.py b/debug_toolbar/utils/functional.py new file mode 100644 index 0000000..1dbb734 --- /dev/null +++ b/debug_toolbar/utils/functional.py @@ -0,0 +1,14 @@ +try: + from django.utils.functional import cached_property +except ImportError: # Django < 1.4 + class cached_property(object): + """ + Decorator that creates converts a method with a single + self argument into a property cached on the instance. + """ + def __init__(self, func): + self.func = func + + def __get__(self, instance, type): + res = instance.__dict__[self.func.__name__] = self.func(instance) + return res -- cgit v1.2.3