From cfc7add4e295ab6efefe048ea0b09676cfb314be Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sat, 17 Nov 2012 18:14:02 -0300 Subject: added "render" shortcut to django1.2 --- askbot/patches/__init__.py | 3 +++ askbot/patches/django_patches.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) 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 -- cgit v1.2.3-1-g7c22