summaryrefslogtreecommitdiffstats
path: root/askbot/patches
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-17 18:14:02 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-17 18:14:02 -0300
commitcfc7add4e295ab6efefe048ea0b09676cfb314be (patch)
tree619de001bd75c11884df9b6bda18871c74b55181 /askbot/patches
parent5b951d7db05a103523eaa9a0729ea0f2909127e8 (diff)
downloadaskbot-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__.py3
-rw-r--r--askbot/patches/django_patches.py13
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