diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
index e55b3bf..a269ee0 100644
a
|
b
|
def prepopulated_fields_js(context):
|
16 | 16 | for inline_admin_form in inline_admin_formset: |
17 | 17 | if inline_admin_form.original is None: |
18 | 18 | prepopulated_fields.extend(inline_admin_form.prepopulated_fields) |
19 | | context.update({'prepopulated_fields': prepopulated_fields}) |
20 | | return context |
| 19 | return {'prepopulated_fields': prepopulated_fields} |
21 | 20 | |
22 | 21 | @register.inclusion_tag('admin/submit_line.html', takes_context=True) |
23 | 22 | def submit_row(context): |
diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py
index dbbd35e..02fd11c 100644
a
|
b
|
def remote_user_auth_view(request):
|
18 | 18 | |
19 | 19 | def auth_processor_no_attr_access(request): |
20 | 20 | r1 = render_to_response('context_processors/auth_attrs_no_access.html', |
21 | | RequestContext(request, {}, processors=[context_processors.auth])) |
| 21 | context_instance=RequestContext(request, {}, processors=[context_processors.auth])) |
22 | 22 | # *After* rendering, we check whether the session was accessed |
23 | 23 | return render_to_response('context_processors/auth_attrs_test_access.html', |
24 | 24 | {'session_accessed':request.session.accessed}) |
25 | 25 | |
26 | 26 | def auth_processor_attr_access(request): |
27 | 27 | r1 = render_to_response('context_processors/auth_attrs_access.html', |
28 | | RequestContext(request, {}, processors=[context_processors.auth])) |
| 28 | context_instance=RequestContext(request, {}, processors=[context_processors.auth])) |
29 | 29 | return render_to_response('context_processors/auth_attrs_test_access.html', |
30 | 30 | {'session_accessed':request.session.accessed}) |
31 | 31 | |
32 | 32 | def auth_processor_user(request): |
33 | 33 | return render_to_response('context_processors/auth_attrs_user.html', |
34 | | RequestContext(request, {}, processors=[context_processors.auth])) |
| 34 | context_instance=RequestContext(request, {}, processors=[context_processors.auth])) |
35 | 35 | |
36 | 36 | def auth_processor_perms(request): |
37 | 37 | return render_to_response('context_processors/auth_attrs_perms.html', |
38 | | RequestContext(request, {}, processors=[context_processors.auth])) |
| 38 | context_instance=RequestContext(request, {}, processors=[context_processors.auth])) |
39 | 39 | |
40 | 40 | def auth_processor_messages(request): |
41 | 41 | info(request, "Message 1") |
42 | 42 | return render_to_response('context_processors/auth_attrs_messages.html', |
43 | | RequestContext(request, {}, processors=[context_processors.auth])) |
| 43 | context_instance=RequestContext(request, {}, processors=[context_processors.auth])) |
44 | 44 | |
45 | 45 | def userpage(request): |
46 | 46 | pass |
diff --git a/django/template/base.py b/django/template/base.py
index e2fc66b..c61f256 100644
a
|
b
|
from functools import partial
|
5 | 5 | from inspect import getargspec |
6 | 6 | |
7 | 7 | from django.conf import settings |
8 | | from django.template.context import (Context, RequestContext, |
| 8 | from django.template.context import (BaseContext, Context, RequestContext, |
9 | 9 | ContextPopException) |
10 | 10 | from django.utils.importlib import import_module |
11 | 11 | from django.utils.itercompat import is_iterable |
… |
… |
class Library(object):
|
1186 | 1186 | else: |
1187 | 1187 | t = get_template(file_name) |
1188 | 1188 | self.nodelist = t.nodelist |
1189 | | new_context = context_class(_dict, **{ |
| 1189 | context_vars = { |
1190 | 1190 | 'autoescape': context.autoescape, |
1191 | 1191 | 'current_app': context.current_app, |
1192 | 1192 | 'use_l10n': context.use_l10n, |
1193 | 1193 | 'use_tz': context.use_tz, |
1194 | | }) |
| 1194 | } |
| 1195 | if isinstance(_dict, BaseContext): |
| 1196 | new_context = _dict |
| 1197 | new_context.update(context_vars) |
| 1198 | else: |
| 1199 | new_context = context_class(_dict, **context_vars) |
1195 | 1200 | # Copy across the CSRF token, if present, because |
1196 | 1201 | # inclusion tags are often used for forms, and we need |
1197 | 1202 | # instructions for using CSRF protection to be as simple |
diff --git a/django/template/loader.py b/django/template/loader.py
index 4185017..20f8ac9 100644
a
|
b
|
def render_to_string(template_name, dictionary=None, context_instance=None):
|
163 | 163 | the templates in the list. Returns a string. |
164 | 164 | """ |
165 | 165 | dictionary = dictionary or {} |
| 166 | assert type(dictionary) is dict, "dictionary parameter must be a dictionary!" |
166 | 167 | if isinstance(template_name, (list, tuple)): |
167 | 168 | t = select_template(template_name) |
168 | 169 | else: |
diff --git a/tests/regressiontests/context_processors/views.py b/tests/regressiontests/context_processors/views.py
index 66e7132..e6bd43f 100644
a
|
b
|
from django.template.context import RequestContext
|
5 | 5 | |
6 | 6 | def request_processor(request): |
7 | 7 | return render_to_response('context_processors/request_attrs.html', |
8 | | RequestContext(request, {}, processors=[context_processors.request])) |
| 8 | context_instance=RequestContext(request, {}, processors=[context_processors.request])) |
diff --git a/tests/regressiontests/templates/custom.py b/tests/regressiontests/templates/custom.py
index 6bbbe35..ad62be2 100644
a
|
b
|
class CustomTagTests(TestCase):
|
181 | 181 | "'inclusion_unlimited_args_kwargs' received multiple values for keyword argument 'eggs'", |
182 | 182 | template.Template, '{% load custom %}{% inclusion_unlimited_args_kwargs 37 eggs="scrambled" eggs="scrambled" %}') |
183 | 183 | |
| 184 | t = template.Template('{% load custom %}{% inclusion_tag_returns_context %}') |
| 185 | self.assertEqual(t.render(c), u'inclusion_returning_context\n') |
| 186 | |
184 | 187 | def test_include_tag_missing_context(self): |
185 | 188 | # The 'context' parameter must be present when takes_context is True |
186 | 189 | self.assertRaisesRegexp(template.TemplateSyntaxError, |
diff --git a/tests/regressiontests/templates/loaders.py b/tests/regressiontests/templates/loaders.py
index 5c11916..e7315ef 100644
a
|
b
|
class RenderToStringTest(unittest.TestCase):
|
153 | 153 | self.assertRaisesRegexp(TemplateDoesNotExist, |
154 | 154 | 'No template names provided$', |
155 | 155 | loader.select_template, []) |
| 156 | |
| 157 | def test_bad_context_instance_position(self): |
| 158 | """ Test that an AssertionError is raised when a Context instance is |
| 159 | passed as the second argument of render_to_string |
| 160 | """ |
| 161 | context = Context({'obj': 'before'}) |
| 162 | with self.assertRaises(AssertionError): |
| 163 | loader.render_to_string('test_context.html', context) |
diff --git a/tests/regressiontests/templates/templatetags/custom.py b/tests/regressiontests/templates/templatetags/custom.py
index 7f78831..cfa727f 100644
a
|
b
|
def inclusion_tag_without_context_parameter(arg):
|
233 | 233 | return {} |
234 | 234 | inclusion_tag_without_context_parameter.anything = "Expected inclusion_tag_without_context_parameter __dict__" |
235 | 235 | |
| 236 | @register.inclusion_tag('inclusion.html', takes_context=True) |
| 237 | def inclusion_tag_returns_context(context): |
| 238 | context.update({"result": "inclusion_returning_context"}) |
| 239 | return context |
| 240 | |
236 | 241 | @register.assignment_tag |
237 | 242 | def assignment_no_params(): |
238 | 243 | """Expected assignment_no_params __doc__""" |