Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted some of the built-in views to use content_type instead of m…

…imetype HttpResponse argument. Refs #16519

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8767439af45d94025210ea13d0d4be465553b855 1 parent d3055b3
@adrianholovaty adrianholovaty authored
View
7 django/contrib/gis/shortcuts.py
@@ -20,7 +20,7 @@ def compress_kml(kml):
def render_to_kml(*args, **kwargs):
"Renders the response as KML (using the correct MIME type)."
return HttpResponse(loader.render_to_string(*args, **kwargs),
- mimetype='application/vnd.google-earth.kml+xml')
+ content_type='application/vnd.google-earth.kml+xml')
def render_to_kmz(*args, **kwargs):
"""
@@ -28,10 +28,9 @@ def render_to_kmz(*args, **kwargs):
MIME type).
"""
return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),
- mimetype='application/vnd.google-earth.kmz')
-
+ content_type='application/vnd.google-earth.kmz')
def render_to_text(*args, **kwargs):
"Renders the response using the MIME type for plain text."
return HttpResponse(loader.render_to_string(*args, **kwargs),
- mimetype='text/plain')
+ content_type='text/plain')
View
4 django/contrib/gis/sitemaps/views.py
@@ -30,7 +30,7 @@ def index(request, sitemaps):
for page in range(2, pages+1):
sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
- return HttpResponse(xml, mimetype='application/xml')
+ return HttpResponse(xml, content_type='application/xml')
def sitemap(request, sitemaps, section=None):
"""
@@ -58,7 +58,7 @@ def sitemap(request, sitemaps, section=None):
except PageNotAnInteger:
raise Http404("No page '%s'" % page)
xml = smart_str(loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls}))
- return HttpResponse(xml, mimetype='application/xml')
+ return HttpResponse(xml, content_type='application/xml')
def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
"""
View
13 django/contrib/sitemaps/views.py
@@ -1,12 +1,10 @@
+from django.contrib.sites.models import get_current_site
from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger
from django.http import Http404
from django.template.response import TemplateResponse
-from django.contrib.sites.models import get_current_site
-
-def index(request, sitemaps,
- template_name='sitemap_index.xml', mimetype='application/xml'):
+def index(request, sitemaps, template_name='sitemap_index.xml', mimetype='application/xml'):
current_site = get_current_site(request)
sites = []
protocol = request.is_secure() and 'https' or 'http'
@@ -21,10 +19,9 @@ def index(request, sitemaps,
if pages > 1:
for page in range(2, pages+1):
sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
- return TemplateResponse(request, template_name, {'sitemaps': sites}, mimetype=mimetype)
+ return TemplateResponse(request, template_name, {'sitemaps': sites}, content_type=mimetype)
-def sitemap(request, sitemaps, section=None,
- template_name='sitemap.xml', mimetype='application/xml'):
+def sitemap(request, sitemaps, section=None, template_name='sitemap.xml', mimetype='application/xml'):
maps, urls = [], []
if section is not None:
if section not in sitemaps:
@@ -43,4 +40,4 @@ def sitemap(request, sitemaps, section=None,
raise Http404("Page %s empty" % page)
except PageNotAnInteger:
raise Http404("No page '%s'" % page)
- return TemplateResponse(request, template_name, {'urlset': urls}, mimetype=mimetype)
+ return TemplateResponse(request, template_name, {'urlset': urls}, content_type=mimetype)
View
2  django/contrib/syndication/views.py
@@ -36,7 +36,7 @@ def __call__(self, request, *args, **kwargs):
except ObjectDoesNotExist:
raise Http404('Feed object does not exist.')
feedgen = self.get_feed(obj, request)
- response = HttpResponse(mimetype=feedgen.mime_type)
+ response = HttpResponse(content_type=feedgen.mime_type)
feedgen.write(response, 'utf-8')
return response
View
2  django/views/generic/simple.py
@@ -25,7 +25,7 @@ def direct_to_template(request, template, extra_context=None, mimetype=None, **k
dictionary[key] = value
c = RequestContext(request, dictionary)
t = loader.get_template(template)
- return HttpResponse(t.render(c), mimetype=mimetype)
+ return HttpResponse(t.render(c), content_type=mimetype)
def redirect_to(request, url, permanent=True, query_string=False, **kwargs):
"""
View
6 docs/ref/request-response.txt
@@ -538,7 +538,7 @@ Typical usage is to pass the contents of the page, as a string, to the
>>> from django.http import HttpResponse
>>> response = HttpResponse("Here's the text of the Web page.")
- >>> response = HttpResponse("Text only, please.", mimetype="text/plain")
+ >>> response = HttpResponse("Text only, please.", content_type="text/plain")
But if you want to add content incrementally, you can use ``response`` as a
file-like object::
@@ -577,10 +577,10 @@ Telling the browser to treat the response as a file attachment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To tell the browser to treat the response as a file attachment, use the
-``mimetype`` argument and set the ``Content-Disposition`` header. For example,
+``content_type`` argument and set the ``Content-Disposition`` header. For example,
this is how you might return a Microsoft Excel spreadsheet::
- >>> response = HttpResponse(my_data, mimetype='application/vnd.ms-excel')
+ >>> response = HttpResponse(my_data, content_type='application/vnd.ms-excel')
>>> response['Content-Disposition'] = 'attachment; filename=foo.xls'
There's nothing Django-specific about the ``Content-Disposition`` header, but

0 comments on commit 8767439

Please sign in to comment.
Something went wrong with that request. Please try again.