Files
2026-etpgrf-site/etpgrf_site/blog/sitemaps.py

15 lines
653 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.contrib.sitemaps import Sitemap
from .models import Post
class PostSitemap(Sitemap):
changefreq = "weekly" # Как часто меняются страницы
priority = 0.9 # Приоритет (от 0.0 до 1.0)
def items(self):
"""Возвращает все опубликованные посты и страницы."""
return Post.objects.filter(is_published=True)
def lastmod(self, obj):
"""Возвращает дату последнего изменения."""
return obj.updated_at # Используем дату обновления, а не публикации