diff options
| author | Vladislav Poluhin | 2013-04-24 16:04:04 +0800 |
|---|---|---|
| committer | Vladislav Poluhin | 2013-04-24 16:04:04 +0800 |
| commit | 702f574461693efe0ea951254e2dcce7edb9a30f (patch) | |
| tree | 9df762ed44e97073afae0c628393bd7f5830fa49 | |
| parent | 4c1c4f7a8873a80f843ba683240b9d0ff0f49e4b (diff) | |
| download | django-debug-toolbar-702f574461693efe0ea951254e2dcce7edb9a30f.tar.bz2 | |
Fix tests for Django 1.3
| -rw-r--r-- | debug_toolbar/forms.py | 3 | ||||
| -rw-r--r-- | debug_toolbar/utils/functional.py | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/debug_toolbar/forms.py b/debug_toolbar/forms.py index 5955bfc..9793f5e 100644 --- a/debug_toolbar/forms.py +++ b/debug_toolbar/forms.py @@ -1,7 +1,8 @@ from django import forms from django.conf import settings from django.core.exceptions import ValidationError -from django.utils.functional import cached_property + +from debug_toolbar.utils.functional import cached_property from debug_toolbar.utils.sql import reformat_sql try: 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 |
