I have a django 1.4.6 project. I am trying to display my blog entries in my template that are not dated in the future, so I cobbled this code in my models.py page, which works:
#if the blog is post/future dated, do not display the blog entry.
@property
def is_past_date_published_blog(self):
if self.blog_post_date_published < date.today():
return True
return False
Now I am wanting to just display the 1st 3 blog entries (I have more than 10 blog entries), so I used a slice:3 as shown below:
{% for blog_post in blog_posts|slice:":3" %}
{% if blog_post.is_past_date_published_blog %}
.......
.......
{% endif %}
{% endfor %}
However, this will only display two entries, as the loop does count the blog entry that is not included by the inner if condition. I have tried to place the for loop inside the if statement, but this does not work. I am now stumped.
How would I write this code to display three blog entries that are before today's date?