diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-11-17 18:14:02 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-11-17 18:14:02 -0300 |
commit | cfc7add4e295ab6efefe048ea0b09676cfb314be (patch) | |
tree | 619de001bd75c11884df9b6bda18871c74b55181 /askbot/patches | |
parent | 5b951d7db05a103523eaa9a0729ea0f2909127e8 (diff) | |
download | askbot-cfc7add4e295ab6efefe048ea0b09676cfb314be.tar.gz askbot-cfc7add4e295ab6efefe048ea0b09676cfb314be.tar.bz2 askbot-cfc7add4e295ab6efefe048ea0b09676cfb314be.zip |
added "render" shortcut to django1.2
Diffstat (limited to 'askbot/patches')
-rw-r--r-- | askbot/patches/__init__.py | 3 | ||||
-rw-r--r-- | askbot/patches/django_patches.py | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/askbot/patches/__init__.py b/askbot/patches/__init__.py index ebaeabac..6145097c 100644 --- a/askbot/patches/__init__.py +++ b/askbot/patches/__init__.py @@ -17,6 +17,9 @@ def patch_django(): django_patches.add_csrf_protection() django_patches.add_available_attrs_decorator() + if major == 1 and minor <=2: + django_patches.add_render_shortcut() + def patch_coffin(): """coffin before version 0.3.4 does not have csrf_token template tag. diff --git a/askbot/patches/django_patches.py b/askbot/patches/django_patches.py index e28c88ba..fe0e2fe7 100644 --- a/askbot/patches/django_patches.py +++ b/askbot/patches/django_patches.py @@ -339,3 +339,16 @@ def add_available_attrs_decorator(): return tuple(a for a in WRAPPER_ASSIGNMENTS if hasattr(fn, a)) import django.utils.decorators django.utils.decorators.available_attrs = available_attrs + +def add_render_shortcut(): + """adds `render` shortcut, introduced with django 1.3""" + try: + from django.shortcuts import render + except ImportError: + def render(request, template, data=None): + from django.shortcuts import render_to_response + from django.template import RequestContext + return render_to_response(template, RequestContext(request, data)) + + import django.shortcuts + django.shortcuts.render = render |