Created
February 10, 2022 08:07
-
-
Save sehrishnaz/da5bf900800404a1b3e2a6a1d81db108 to your computer and use it in GitHub Desktop.
Create Dynamic Sitemap in Django Using Multiple Models Slug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.sitemaps import Sitemap | |
from .models import Your_Model_Name | |
class MySitemap(Sitemap): | |
changefreq = "weekly" | |
priority = 0.8 | |
protocol = 'http' | |
def items(self): | |
return Your_Model_Name.objects.all() | |
def lastmod(self, obj): | |
return obj.modified_date_field_goes_here | |
def location(self,obj): | |
return '/%s/%s' % (obj.foriegn_key_field.your_slug_field,obj.your_slug_field_goes_here) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create Dynamic Sitemap in Django Using Multiple Models Slug