I want to make a dynamic sitemap generation on the site (django) simply through a normal view and html template.

class SitemapView(View): def get(self, request): context={ #something } return render(request, 'shop/sitemap.html', context=context) 

It should be launched at site.ru/sitemap.xml. Accordingly, in urls.py I write:

 urlpatterns = [ path('sitemap.xml', SitemapView.as_view(), name='sitemap_view'), ] 

Django adds a slash at the end, like all other pages. Can I somehow make an exception and not add a slash at the end to this particular address?

1 answer 1

You can disable the automatic addition of slashes.

APPEND_SLASH = False

  • But then redirects will disappear everywhere, and I want only on one page: ( - Konstantin Komissarov