diff --git a/AUTHORS b/AUTHORS
index 923d6e60081..a605cb2105e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -160,6 +160,7 @@ answer newbie questions, and generally made Django that much better:
Amit Upadhyay
Geert Vanderkelen
Milton Waddams
+ wam-djangobug@wamber.net
Dan Watson
Rachel Willmer
Gary Wilson
diff --git a/django/views/generic/simple.py b/django/views/generic/simple.py
index 325288d52f8..355bd25ef83 100644
--- a/django/views/generic/simple.py
+++ b/django/views/generic/simple.py
@@ -2,12 +2,18 @@ from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
-def direct_to_template(request, template, **kwargs):
+def direct_to_template(request, template, extra_context={}, **kwargs):
"""
Render a given template with any extra URL parameters in the context as
``{{ params }}``.
"""
- return render_to_response(template, {'params' : kwargs}, context_instance=RequestContext(request))
+ dictionary = {'params': kwargs}
+ for key, value in extra_context.items():
+ if callable(value):
+ dictionary[key] = value()
+ else:
+ dictionary[key] = value
+ return render_to_response(template, dictionary, context_instance=RequestContext(request))
def redirect_to(request, url, **kwargs):
"""
diff --git a/docs/generic_views.txt b/docs/generic_views.txt
index 99a9b7cf6b9..f0c3f738f30 100644
--- a/docs/generic_views.txt
+++ b/docs/generic_views.txt
@@ -92,6 +92,13 @@ which is a dictionary of the parameters captured in the URL.
* ``template``: The full name of a template to use.
+**Optional arguments:**
+
+ * ``extra_context``: A dictionary of values to add to the template
+ context. By default, this is an empty dictionary. If a value in the
+ dictionary is callable, the generic view will call it
+ just before rendering the template.
+
**Example:**
Given the following URL patterns::
@@ -171,7 +178,7 @@ a date in the *future* are not included unless you set ``allow_future`` to
template. By default, it's ``django.template.loader``.
* ``extra_context``: A dictionary of values to add to the template
- context. By default, this is an empty dictionary.
+ context. By default, this is an empty dictionary. If a value in the
dictionary is callable, the generic view will call it
just before rendering the template.