Site/blog/feeds.py
2026-03-08 17:30:37 +03:00

23 lines
902 B
Python
Raw Permalink 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.syndication.views import Feed
from django.urls import reverse
from .models import Article
class LatestArticlesFeed(Feed):
title = "Блог программиста 1ССНА Технологии"
description = "Свежие статьи о 1С, автоматизации и разработке"
link = "/blog/"
def items(self):
# Возвращаем последние 10 опубликованных статей
return Article.objects.filter(is_published=True).order_by('-time_create')[:10]
def item_title(self, item):
return item.title
def item_description(self, item):
# Краткое описание (можно первые 200 символов контента)
return item.content[:200] + ""
def item_link(self, item):
return reverse('blog:article_detail', args=[item.slug])