from django.contrib.sitemaps.views import x_robots_tag
@x_robots_tag
def xml_sitemap(request):
sitemap_file = 'sitemap.xml'
try:
with open(sitemap_file) as file:
return HttpResponse(file.read(), content_type='application/xml')
except IOError:
raise Http404