Code

Ticket #1504: __init__.py.3.diff

File __init__.py.3.diff, 743 bytes (added by Rob van der Linde, 7 years ago)

Add support for mimetype in render_to_response() function

Line 
1--- shortcuts/__init__.py       2007-09-13 23:02:15.000000000 +1200
2+++ shortcuts/__init__.py       2007-09-13 23:13:01.000000000 +1200
3@@ -14,7 +14,12 @@
4     Returns a HttpResponse whose content is filled with the result of calling
5     django.template.loader.render_to_string() with the passed arguments.
6     """
7-    return HttpResponse(loader.render_to_string(*args, **kwargs))
8+    if "mimetype" in kwargs:
9+        mimetype = kwargs["mimetype"]
10+        del kwargs["mimetype"]
11+        return HttpResponse(loader.render_to_string(*args, **kwargs), mimetype=mimetype)
12+    else:
13+        return HttpResponse(loader.render_to_string(*args, **kwargs))
14 load_and_render = render_to_response # For backwards compatibility.
15 
16 def _get_queryset(klass):