How to use django sitemap Framework for https?

Last updated 4 months, 1 week ago | 199 views 75     5

To ensure your Django sitemap uses HTTPS, you can specify the protocol by adding it as a class variable in your sitemap class.

Solution: Define Protocol in Sitemap Class

Django's sitemap framework uses 'http' as the default protocol. To enforce HTTPS, set the protocol class variable to 'https' in your sitemap class.

from django.contrib.sitemaps import Sitemap
from article.models import Article


class ArticleSitemap(Sitemap):
    changefreq = "hourly"
    priority = 0.9
    protocol = 'https' # for https add protocol

    def items(self):
        return Article.objects.filter(status=1)