From 936a46cc89dda9971ef1b8099cb260e98dbf50a7 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 9 Apr 2007 13:11:39 +0000 Subject: [PATCH] Fixed #3034 -- Added mimetype parameter to the direct_to_template() generic 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 --- AUTHORS | 1 + django/views/generic/simple.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index e0c915512b0..2fecddf36a9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -60,6 +60,7 @@ answer newbie questions, and generally made Django that much better: Andrew Brehaut brut.alll@gmail.com Jonathan Buchanan + Paul Bx Antonio Cavedoni C8E Chris Chamberlin diff --git a/django/views/generic/simple.py b/django/views/generic/simple.py index 355bd25ef83..69a494931e3 100644 --- a/django/views/generic/simple.py +++ b/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): """