Allow template render to string helper functions to accept Context (#372)

* Add failing test case for render_to_string

* Allow Context objects in template render functions
This commit is contained in:
Pavel Savchenko
2020-05-23 12:47:39 +02:00
committed by GitHub
parent 6f5a39625e
commit 64cbb0f70e
3 changed files with 20 additions and 3 deletions

View File

@@ -0,0 +1,15 @@
- case: loader_render_to_string_accepts_context
main: |
from django.http.request import HttpRequest
from django.shortcuts import render, render_to_response
from django.template.loader import render_to_string
from django.template import Context, RequestContext
request = HttpRequest()
request_context = RequestContext(request, {'foo': 'bar'})
render_to_string('foobar', {'foo': 'bar'})
render_to_string('foobar', Context({'foo': 'bar'}))
render_to_string('foobar', request_context)
render(request, '403.html', request_context, status=403)
render_to_response('403.html', request_context)