-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeeds.py
More file actions
37 lines (28 loc) · 982 Bytes
/
feeds.py
File metadata and controls
37 lines (28 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from django.db import models
from django.contrib.syndication.views import Feed
from django.urls import reverse
from blog.models import BlogPage
class BlogsFeedAmp(Feed):
title = "My blog articles in amp format"
link = "/blogs-feed-amp/"
description = "All of my blogs as they are published"
def items(self):
return BlogPage.objects.live().order_by('-date')
def item_title(self, item):
return item.title
def item_description(self, item):
return item.intro
def item_link(self, item):
base_url = item.get_absolute_url()
amp_url = base_url + "amp"
return amp_url
class BlogsFeed(Feed):
title = "My blog articles"
link = "/blogs-feed/"
description = "All of my blogs as they are published"
def items(self):
return BlogPage.objects.live().order_by('-date')
def item_title(self, item):
return item.title
def item_description(self, item):
return item.intro