Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #3034 -- Added mimetype parameter to the direct_to_template() g…

…eneric

view, for consistency with the other generic views. Thanks, Paul Bx.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@4983 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 936a46cc89dda9971ef1b8099cb260e98dbf50a7 1 parent 3720154
@malcolmt malcolmt authored
Showing with 6 additions and 3 deletions.
  1. +1 −0  AUTHORS
  2. +5 −3 django/views/generic/simple.py
View
1  AUTHORS
@@ -60,6 +60,7 @@ answer newbie questions, and generally made Django that much better:
Andrew Brehaut <http://brehaut.net/blog>
brut.alll@gmail.com
Jonathan Buchanan <jonathan.buchanan@gmail.com>
+ Paul Bx <pb@e-scribe.com>
Antonio Cavedoni <http://cavedoni.com/>
C8E
Chris Chamberlin <dja@cdc.msbx.net>
View
8 django/views/generic/simple.py
@@ -1,8 +1,8 @@
from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.template import loader, RequestContext
from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
-def direct_to_template(request, template, extra_context={}, **kwargs):
+def direct_to_template(request, template, extra_context={}, mimetype=None, **kwargs):
"""
Render a given template with any extra URL parameters in the context as
``{{ params }}``.
@@ -13,7 +13,9 @@ def direct_to_template(request, template, extra_context={}, **kwargs):
dictionary[key] = value()
else:
dictionary[key] = value
- return render_to_response(template, dictionary, context_instance=RequestContext(request))
+ c = RequestContext(request, dictionary)
+ t = loader.get_template(template)
+ return HttpResponse(t.render(c), mimetype=mimetype)
def redirect_to(request, url, **kwargs):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.