-
-
Notifications
You must be signed in to change notification settings - Fork 672
Expand file tree
/
Copy pathblogs.py
More file actions
25 lines (17 loc) · 665 Bytes
/
blogs.py
File metadata and controls
25 lines (17 loc) · 665 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
"""Template tags for displaying blog entries in templates."""
from django import template
from apps.blogs.models import BlogEntry
register = template.Library()
@register.simple_tag
def get_latest_blog_entries(limit=5):
"""Return limit of latest blog entries."""
return BlogEntry.objects.order_by("-pub_date")[:limit]
@register.simple_tag
def feed_list(slug, limit=10):
"""Return a list of blog entries for the given FeedAggregate slug.
{% feed_list 'psf' as entries %}
{% for entry in entries %}
{{ entry }}
{% endfor %}
"""
return BlogEntry.objects.filter(feed__feedaggregate__slug=slug).order_by("-pub_date")[:limit]