mod: современный способ создания sitemap.xml

This commit is contained in:
2026-02-18 16:00:52 +03:00
parent 33fa2d04a9
commit 65feb36f77
7 changed files with 68 additions and 29 deletions

20
dicquo/web/sitemaps.py Normal file
View File

@@ -0,0 +1,20 @@
from django.contrib.sitemaps import Sitemap
from web.models import TbDictumAndQuotes
import pytils
class DictumSitemap(Sitemap):
changefreq = "weekly" # Как часто меняются страницы
priority = 0.9 # Приоритет (от 0.0 до 1.0)
def items(self):
# Only show checked items in sitemap
return TbDictumAndQuotes.objects.filter(bIsChecked=True).order_by('-id')
def lastmod(self, obj):
return obj.dtEdited
def location(self, obj):
# Generates URL in format: /123_slug
slug = pytils.translit.slugify(obj.szContent.lower())[:120]
return f"/{obj.id}_{slug}"