diff --git a/AUTHORS b/AUTHORS index 01908ad6c9..c8054c9e20 100644 --- a/AUTHORS +++ b/AUTHORS @@ -627,6 +627,7 @@ answer newbie questions, and generally made Django that much better: Nasir Hussain Natalia Bidart Nate Bragg + Nathan Gaberel Neal Norwitz Nebojša Dorđević Ned Batchelder diff --git a/django/template/engine.py b/django/template/engine.py index dfaa67ba12..ff9ce58d59 100644 --- a/django/template/engine.py +++ b/django/template/engine.py @@ -160,7 +160,7 @@ class Engine: if isinstance(context, Context): return t.render(context) else: - return t.render(Context(context)) + return t.render(Context(context, autoescape=self.autoescape)) def select_template(self, template_name_list): """ diff --git a/tests/template_tests/test_engine.py b/tests/template_tests/test_engine.py index 2bb8601fbb..b975ea87b4 100644 --- a/tests/template_tests/test_engine.py +++ b/tests/template_tests/test_engine.py @@ -21,6 +21,13 @@ class RenderToStringTest(SimpleTestCase): 'obj:test\n', ) + def test_autoescape_off(self): + engine = Engine(dirs=[TEMPLATE_DIR], autoescape=False) + self.assertEqual( + engine.render_to_string('test_context.html', {'obj': '