#15572: include with "only" option discards context properties (such as autoescape) -------------------------------------+------------------------------------- Reporter: dfoerster | Owner: nobody Status: closed | Milestone: 1.3 Component: Template | Version: SVN system | Keywords: include, autoescape, Resolution: fixed | blocker Triage Stage: Accepted | Has patch: 1 Needs documentation: 0 | Needs tests: 1 Patch needs improvement: 0 | -------------------------------------+-------------------------------------
Comment (by mk): The specific circumstances are when the context used when rending is a RequestContext, not a Context instance. The problem can be spotted quite easily. Just apply this patch and see many many test failures: {{{ diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 10c7a37..6d90349 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -15,7 +15,7 @@ import traceback from django import template from django.template import base as template_base from django.core import urlresolvers -from django.template import loader +from django.template import RequestContext, loader from django.template.loaders import app_directories, filesystem, cached from django.utils import unittest from django.utils.translation import activate, deactivate, ugettext as _ @@ -493,7 +493,7 @@ class Templates(unittest.TestCase): ('-'*70, ("\n%s\n" % ('-'*70)).join(failures))) def render(self, test_template, vals): - context = template.Context(vals[1]) + context = template.RequestContext(None, vals[1]) before_stack_size = len(context.dicts) output = test_template.render(context) if len(context.dicts) != before_stack_size: }}} The exception the one listed above: {{{ TemplateSyntaxError: Caught TypeError while rendering: __init__() got an unexpected keyword argument 'autoescape' }}} ... where !__init!__ equals !RequestContext.!__init!__ -- Ticket URL: <http://code.djangoproject.com/ticket/15572#comment:6> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.