summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/views/generic/base.py6
-rw-r--r--docs/releases/1.5.txt8
-rw-r--r--tests/regressiontests/generic_views/base.py4
3 files changed, 13 insertions, 5 deletions
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index ca039ae9db..e11412ba4d 100644
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -142,11 +142,11 @@ class TemplateResponseMixin(object):
class TemplateView(TemplateResponseMixin, ContextMixin, View):
"""
- A view that renders a template. This view is different from all the others
- insofar as it also passes ``kwargs`` as ``params`` to the template context.
+ A view that renders a template. This view will also pass into the context
+ any keyword arguments passed by the url conf.
"""
def get(self, request, *args, **kwargs):
- context = self.get_context_data(params=kwargs)
+ context = self.get_context_data(**kwargs)
return self.render_to_response(context)
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index 29cbd45c49..4f25919d79 100644
--- a/docs/releases/1.5.txt
+++ b/docs/releases/1.5.txt
@@ -144,6 +144,14 @@ year|date:"Y" }}``.
``next_year`` and ``previous_year`` were also added in the context. They are
calculated according to ``allow_empty`` and ``allow_future``.
+Context in TemplateView
+~~~~~~~~~~~~~~~~~~~~~~~
+
+For consistency with the design of the other generic views,
+:class:`~django.views.generic.base.TemplateView` no longer passes a ``params``
+dictionary into the context, instead passing the variables from the URLconf
+directly into the context.
+
OPTIONS, PUT and DELETE requests in the test client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py
index b9f64888fc..a61b01be0b 100644
--- a/tests/regressiontests/generic_views/base.py
+++ b/tests/regressiontests/generic_views/base.py
@@ -275,7 +275,7 @@ class TemplateViewTest(TestCase):
"""
response = self.client.get('/template/simple/bar/')
self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['params'], {'foo': 'bar'})
+ self.assertEqual(response.context['foo'], 'bar')
self.assertTrue(isinstance(response.context['view'], View))
def test_extra_template_params(self):
@@ -284,7 +284,7 @@ class TemplateViewTest(TestCase):
"""
response = self.client.get('/template/custom/bar/')
self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['params'], {'foo': 'bar'})
+ self.assertEqual(response.context['foo'], 'bar')
self.assertEqual(response.context['key'], 'value')
self.assertTrue(isinstance(response.context['view'], View))