diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index b90a39e..a8bb374 100644
a
|
b
|
|
1 | 1 | from django.contrib.sites.models import get_current_site |
2 | 2 | from django.core import urlresolvers |
3 | 3 | from django.core.paginator import EmptyPage, PageNotAnInteger |
4 | | from django.http import Http404 |
5 | | from django.template.response import TemplateResponse |
| 4 | from django.http import Http404, HttpResponse |
| 5 | from django.template import loader |
| 6 | from django.utils.encoding import smart_str |
| 7 | |
6 | 8 | |
7 | 9 | def index(request, sitemaps, |
8 | 10 | template_name='sitemap_index.xml', mimetype='application/xml', |
… |
… |
def index(request, sitemaps,
|
22 | 24 | for page in range(2, site.paginator.num_pages + 1): |
23 | 25 | sites.append('%s?p=%s' % (absolute_url, page)) |
24 | 26 | |
25 | | return TemplateResponse(request, template_name, {'sitemaps': sites}, |
26 | | content_type=mimetype) |
| 27 | xml = loader.render_to_string(template_name, {'sitemaps': sites}) |
| 28 | response = HttpResponse(xml, mimetype=mimetype) |
| 29 | response['X-Robots-Tag'] = 'noindex, noodp, noarchive' |
| 30 | return response |
| 31 | |
27 | 32 | |
28 | 33 | def sitemap(request, sitemaps, section=None, |
29 | 34 | template_name='sitemap.xml', mimetype='application/xml'): |
… |
… |
def sitemap(request, sitemaps, section=None,
|
49 | 54 | raise Http404("Page %s empty" % page) |
50 | 55 | except PageNotAnInteger: |
51 | 56 | raise Http404("No page '%s'" % page) |
52 | | return TemplateResponse(request, template_name, {'urlset': urls}, |
53 | | content_type=mimetype) |
| 57 | |
| 58 | xml = smart_str(loader.render_to_string(template_name, {'urlset': urls})) |
| 59 | response = HttpResponse(xml, mimetype=mimetype) |
| 60 | response['X-Robots-Tag'] = 'noindex, noodp, noarchive' |
| 61 | return response |
| 62 | |