diff options
author | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-04 03:08:47 +0300 |
---|---|---|
committer | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-04 03:08:47 +0300 |
commit | 3f5e2e80c6c888acb20155ebf82301ed01e92c0e (patch) | |
tree | f214b763791969fdcd2355ee5c7c67b3a1575c6d /weblog/feeds.py | |
parent | 5bd41b3886cfded2a5eced4d32de5638d183ea8c (diff) | |
download | w3blog-3f5e2e80c6c888acb20155ebf82301ed01e92c0e.tar.gz w3blog-3f5e2e80c6c888acb20155ebf82301ed01e92c0e.zip |
fix unpublished post appearing on rss feed
Diffstat (limited to 'weblog/feeds.py')
-rw-r--r-- | weblog/feeds.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/weblog/feeds.py b/weblog/feeds.py index 59fcd8f..bb5c65c 100644 --- a/weblog/feeds.py +++ b/weblog/feeds.py @@ -5,6 +5,7 @@ from weblog.models import BlogPost, Translation, Category, CategoryTranslation from weblog.apps import SETTINGS as blog_settings from django.utils.translation import ugettext_lazy as _, pgettext_lazy from django.utils import translation +import datetime class BlogFeed(Feed): @@ -43,9 +44,10 @@ class BlogFeed(Feed): return _('Latest blog posts on %(blog_title)s') % {'blog_title': blog_settings['blog_title']} def items(self, obj): + now = datetime.datetime.now() if obj: - return BlogPost.objects.filter(category__slug=obj).order_by('-publish_date')[:blog_settings['posts_per_page']] - return BlogPost.objects.order_by('-publish_date')[:blog_settings['posts_per_page']] + return BlogPost.objects.filter(category__slug=obj, published=True, publish_date__lte=now).order_by('-publish_date')[:blog_settings['posts_per_page']] + return BlogPost.objects.order_by('-publish_date').filter(published=True, publish_date__lte=now)[:blog_settings['posts_per_page']] def item_title(self, item): translation_exists = False |