Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #urls.py
- ---------------
- sitemaps = {
- 'static': StaticViewSitemap,
- 'blog': BlogSitemap,
- }
- urlpatterns = [
- path('admin/', admin.site.urls),
- path('i18n/', include('django.conf.urls.i18n')),
- path('sitemap.xml', sitemap, {'sitemaps': sitemaps},name='django.contrib.sitemaps.views.sitemap'),
- ]
- -----------------
- #models.py
- -----------------
- blablabla typical Posts model with:
- def get_absolute_url(self):
- return reverse('blog:post', kwargs={'slug':self.slug})
- ------------------
- #sitemaps
- -----------------
- class StaticViewSitemap(Sitemap):
- priority = 0.5
- changefreq = 'daily'
- protocol = "https"
- def items(self):
- return ['main:contact-us', 'main:homepage','blog:blog']
- def location(self, item):
- return reverse(item)
- class BlogSitemap(Sitemap):
- changfreq = "daily"
- priority = 1.0
- def items(self):
- return Post.objects.filter(status='p')
- def lastmod(self, obj):
- return obj.published
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement