Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor Template.render()

- Template now subclasses Jinja2.Template, like it should have all along
- We now fire off template rendered signals.
- This now works in Django Debug Toolbar (thanks for the pointers @robhudson)
  • Loading branch information...
commit f1b0367b20817f3d4c2d1a0c11a2724828015936 1 parent 5d73f69
@davedash davedash authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 jingo/__init__.py
View
8 jingo/__init__.py
@@ -2,6 +2,7 @@
import functools
import imp
import logging
+import warnings
from django import http
from django.conf import settings
@@ -69,8 +70,8 @@ def render(request, template, context=None, **kwargs):
.. deprecated:: 0.4
use ``django.shortcuts.render()``
"""
- log.warning('jingo.render() has been deprecated. '
- 'Use django.shortcuts.render().')
+ warnings.warn('jingo.render() has been deprecated. Use '
+ 'django.shortcuts.render().', DeprecationWarning)
rendered = render_to_string(request, template, context)
return http.HttpResponse(rendered, **kwargs)
@@ -172,10 +173,13 @@ def render(self, context={}):
else:
context_dict = context
+ # Django Debug Toolbar needs a RequestContext-like object in order
+ # to inspect context.
class FakeRequestContext:
dicts = [context]
context = FakeRequestContext()
+ # Used by debug_toolbar.
if settings.TEMPLATE_DEBUG:
from django.test import signals
self.origin = Origin(self.filename)
Please sign in to comment.
Something went wrong with that request. Please try again.