def get(self): """ If the user is logged in then render the existing blog posts """ current_user = self.authenticate_user() posts = Post.query().fetch() if current_user: self.render("main.html", posts=posts, current_user=current_user) else: self.render("main.html", posts=posts)
def get(self): template_values = {'posts': []} posts = Post.query().order(-Post.created) for post in posts: template_values['posts'].append({ 'title': post.title, 'content': post.content, 'created': post.created.strftime('%B %d, %Y'), 'id': post.key.id(), }) print template_values self.render('index', template_values)
def get(self): q = Post.query().order(-Post.created) posts = q.fetch(limit=10) if posts: self.render("main.html", posts=posts)