mirror of
https://github.com/django/django.git
synced 2024-12-26 11:06:07 +00:00
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
This commit is contained in:
parent
bb87b2163c
commit
63994a9801
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user