1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #15010 -- Added current_app parameter to close gap between TemplateResponse and render method. Thanks, acdha.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15153 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel
2011-01-05 22:41:43 +00:00
parent 093009bf1f
commit a3894945b6
9 changed files with 62 additions and 7 deletions

View File

@@ -29,7 +29,18 @@ def render(request, *args, **kwargs):
'content_type': kwargs.pop('content_type', None),
'status': kwargs.pop('status', None),
}
kwargs['context_instance'] = kwargs.get('context_instance', RequestContext(request))
if 'context_instance' in kwargs:
context_instance = kwargs.pop('context_instance')
if kwargs.get('current_app', None):
raise ValueError('If you provide a context_instance you must '
'set its current_app before calling render()')
else:
current_app = kwargs.pop('current_app', None)
context_instance = RequestContext(request, current_app=current_app)
kwargs['context_instance'] = context_instance
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)