I'm using https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/?from=olddocs .
I have a sitemap generated from api.mydomain.me for the domain: mydomain.com.
Can I, with django, specify a base url ?
Now with location() method return:
api.mydomain.me/page/3123 instead of mydomain.com/page/3123
Is this possible? Thanks.
Solved, I redefined my own get_urls. It works:
class MySitemap(Sitemap):
changefreq = "never"
priority = 0.5
location = ""
def get_urls(self, site=None, **kwargs):
site = Site(domain='mydomain.com', name='mydomain.com')
return super(MySitemap, self).get_urls(site=site, **kwargs)
def items(self):
return MyObj.objects.all().order_by('pk')[:1000]
def lastmod(self, obj):
return obj.timestamp
I didn't know how to use Site
in my code by using previous answers so I used below code:
class Site:
domain = 'my_site.com'
class MySitemap(Sitemap):
def get_urls(self, site=None, **kwargs):
site = Site()
return super(MySitemap, self).get_urls(site=site, **kwargs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With