diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-09-21 17:24:33 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-09-21 17:24:33 +0000 |
| commit | 63994a980131e15f08383fb441b26d259bd73f7f (patch) | |
| tree | 166588f034e19aa0e715f2544c0ffeb03420e5ca | |
| parent | bb87b2163c7661f64778b00ca7c52b4ba8011a43 (diff) | |
Added django.core.extensions.load_and_render, which factors out the boilerplate of loading a template, rendering a context and returning an HttpResponse
git-svn-id: http://code.djangoproject.com/svn/django/trunk@655 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/extensions.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/core/extensions.py b/django/core/extensions.py index 753e600f23..453d48e8a3 100644 --- a/django/core/extensions.py +++ b/django/core/extensions.py @@ -1,7 +1,16 @@ # Specialized template classes for Django, decoupled from the basic template system. +from django.core import template_loader from django.core.template import Context from django.conf.settings import DEBUG, INTERNAL_IPS +from django.utils.httpwrappers import HttpResponse + +def load_and_render(template_name, dictionary=None, context_class=None): + dictionary = dictionary or {} + context_class = context_class or Context + t = template_loader.get_template(template_name) + c = context_class(dictionary) + return HttpResponse(t.render(c)) class DjangoContext(Context): """ |
