On ajoute les pages des catégories aux sitemap
This commit is contained in:
parent
a7e5645db0
commit
8541adc3d9
@ -1,6 +1,7 @@
|
|||||||
from django.contrib import sitemaps
|
from django.contrib import sitemaps
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
from .models import Category
|
||||||
|
|
||||||
class StaticViewSitemap(sitemaps.Sitemap):
|
class StaticViewSitemap(sitemaps.Sitemap):
|
||||||
priority = 0.5
|
priority = 0.5
|
||||||
@ -10,4 +11,28 @@ class StaticViewSitemap(sitemaps.Sitemap):
|
|||||||
return ["home", "cette_semaine", "ce_mois_ci", "aujourdhui", "a_venir", "about", "contact"]
|
return ["home", "cette_semaine", "ce_mois_ci", "aujourdhui", "a_venir", "about", "contact"]
|
||||||
|
|
||||||
def location(self, item):
|
def location(self, item):
|
||||||
return reverse(item)
|
return reverse(item)
|
||||||
|
|
||||||
|
class HomeCategorySitemap(sitemaps.Sitemap):
|
||||||
|
priority = 0.5
|
||||||
|
changefreq = "daily"
|
||||||
|
path = "home_category"
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
result = []
|
||||||
|
return Category.objects.values_list("slug", flat=True)
|
||||||
|
|
||||||
|
def location(self, item):
|
||||||
|
return reverse(self.path, kwargs={'cat': item})
|
||||||
|
|
||||||
|
class MonthCategorySitemap(HomeCategorySitemap):
|
||||||
|
priority = 0.3
|
||||||
|
path = "ce_mois_ci_category"
|
||||||
|
|
||||||
|
class WeekCategorySitemap(HomeCategorySitemap):
|
||||||
|
priority = 0.4
|
||||||
|
path = "cette_semaine_category"
|
||||||
|
|
||||||
|
class UpcomingCategorySitemap(HomeCategorySitemap):
|
||||||
|
priority = 0.4
|
||||||
|
path = "a_venir_category"
|
||||||
|
@ -6,7 +6,7 @@ from django.urls import path, include, re_path
|
|||||||
from django.views.i18n import JavaScriptCatalog
|
from django.views.i18n import JavaScriptCatalog
|
||||||
from django.contrib.sitemaps.views import sitemap
|
from django.contrib.sitemaps.views import sitemap
|
||||||
from django.contrib.sitemaps import GenericSitemap
|
from django.contrib.sitemaps import GenericSitemap
|
||||||
from .sitemaps import StaticViewSitemap
|
from .sitemaps import *
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
from .views import *
|
from .views import *
|
||||||
@ -31,6 +31,10 @@ sitemaps = {
|
|||||||
"events": GenericSitemap(event_dict, priority=1.0),
|
"events": GenericSitemap(event_dict, priority=1.0),
|
||||||
"places": GenericSitemap(place_dict, priority=0.6),
|
"places": GenericSitemap(place_dict, priority=0.6),
|
||||||
"categories": GenericSitemap(category_dict, priority=0.8),
|
"categories": GenericSitemap(category_dict, priority=0.8),
|
||||||
|
"home_categories": HomeCategorySitemap,
|
||||||
|
"upcoming_categories": UpcomingCategorySitemap,
|
||||||
|
"week_categories": WeekCategorySitemap,
|
||||||
|
"month_categories": MonthCategorySitemap,
|
||||||
"organisations": GenericSitemap(organisation_dict, priority=0.2),
|
"organisations": GenericSitemap(organisation_dict, priority=0.2),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user