1
0

sitemaps.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from django.contrib.sitemaps import Sitemap
  2. from blog.models import Blog, Cat_Blog
  3. from core.models import Page
  4. from django.urls import reverse
  5. class BlogSitemap(Sitemap):
  6. """Sitemap pour les articles de blog"""
  7. changefreq = "weekly"
  8. priority = 0.8
  9. protocol = 'https'
  10. def items(self):
  11. return Blog.objects.filter(b_publier=True).order_by('-b_publdate')
  12. def lastmod(self, obj):
  13. return obj.b_publdate
  14. def location(self, obj):
  15. return reverse('blog_play', args=[obj.b_titre_slugify])
  16. class CategorySitemap(Sitemap):
  17. """Sitemap pour les catégories"""
  18. changefreq = "monthly"
  19. priority = 0.6
  20. protocol = 'https'
  21. def items(self):
  22. return Cat_Blog.objects.all()
  23. def location(self, obj):
  24. return reverse('blog_tag', args=[obj.cb_titre_slgify])
  25. class PageSitemap(Sitemap):
  26. """Sitemap pour les pages statiques"""
  27. changefreq = "monthly"
  28. priority = 0.5
  29. protocol = 'https'
  30. def items(self):
  31. return Page.objects.filter(p_publier=True, p_type='page')
  32. def location(self, obj):
  33. return obj.p_adresse
  34. class StaticViewSitemap(Sitemap):
  35. """Sitemap pour les vues statiques"""
  36. priority = 0.5
  37. changefreq = 'monthly'
  38. protocol = 'https'
  39. def items(self):
  40. return ['blog_index']
  41. def location(self, item):
  42. return reverse(item)