django-blog-for-html-over-t.../app/website/feed.py

22 lines
504 B
Python
Raw Permalink Normal View History

2022-05-15 20:58:36 +02:00
from django.contrib.syndication.views import Feed
from django.urls import reverse
from .models import Post
class LatestEntriesFeed(Feed):
title = "My blog"
link = "/feed/"
description = "Updates to posts."
def items(self):
return Post.objects.all()[:5]
def item_title(self, item):
return item.title
def item_description(self, item):
return item.summary
def item_link(self, item):
return reverse("single post", kwargs={"slug": item.slug})