The following code in a Django view:
def sitemap(request):
return render(request, 'sitemap.xml', content_type = 'text/xml')
yields the following error:
Exception Type: UnicodeDecodeError
Exception Value:
'utf8' codec can't decode byte 0xff in position 0: invalid start byte
How can I resolve this? All I'm trying to do is to render an XML sitemap. Any help would be appreciated. Thanks.
Django support built-in sitemap,here is a demo:
common/sitemaps.py
your peoject main url.py:
doc is here.