Skip to content

Instantly share code, notes, and snippets.

@a5an0
Created January 7, 2014 17:44
Show Gist options
  • Save a5an0/8303298 to your computer and use it in GitHub Desktop.
Save a5an0/8303298 to your computer and use it in GitHub Desktop.
django view to get and render a the most recent *limit* posts on www.alexschoof.com
def post_list(request, limit):
posts_table = get_posts_table()
recent_posts = [x for x in posts_table.query(postType__eq="blog:posts", timePosted__gt=0, limit=limit, reverse=False)]
for post in recent_posts:
post["datetimePosted"] = datetime.datetime.fromtimestamp(post["timePosted"])
return render(request, "post_list.html", {
"posts": recent_posts,
"sitewide_settings": sitewide_settings
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment