Created
January 7, 2014 17:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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