Get In Touch
TC 73/1214,Enchakal
Vallakadavu(PO), Thiruvananthapuram,
Kerala- 695008.

How to add https in django sitemap

How can we add https to sitemap generated url in Django.

We just need to use property called protocol.

from django.contrib.sitemaps import Sitemap
from blog.models import Entry
from django.contrib.sites.models import Site

class BlogSitemap(Sitemap):
    changefreq = "never"
    priority = 0.5
    protocol = "https"

    def get_urls(self, site=None, **kwargs):
        site = Site(domain='foo.com', name='foo.com')
        return super(BlogSitemap, self).get_urls(site=site, **kwargs)

    def items(self):
        return Entry.objects.filter(is_draft=False)

    def lastmod(self, obj):
        return obj.pub_date

 

This website stores cookies on your computer.

START A CONVERSATION

Please enable JavaScript in your browser to complete this form.

Junior Scrum Master

Business Development Executive

Business Operation Analyst

Senior Python Django Developer

Technical Project Manager

React JS Developer

MBA Fresher Recruitment ( 2022 & 2023 passed out)