partirdezero/devart/sitemap.py

29 lines
No EOL
812 B
Python

from django.contrib import sitemaps
from django.urls import reverse
# --- IMPORTS DEPUIS TES DIFFÉRENTES FEATURES ---
from courses.models import Course
from users.models import Profile
# --- SITEMAP : LES Cours ---
class CourseSitemap(sitemaps.Sitemap):
changefreq = "weekly"
priority = 0.9
def items(self):
return Course.objects.filter(enable=True) # Exemple de filtre
def location(self, item):
# Assure-toi que ton modèle Course a bien une méthode get_absolute_url
return item.get_absolute_url()
# --- SITEMAP : PAGES STATIQUES ---
class StaticViewSitemap(sitemaps.Sitemap):
priority = 0.5
changefreq = "monthly"
def items(self):
return ["home"] # Les noms de tes URLs
def location(self, item):
return "https://partirdezero.com"