示例#1
0
文件: views.py 项目: phocode/myblog
 def get(self, tag):
   posts = Post.objects(tags=tag)
   tags = Post.objects.distinct("tags")
   all_tags = []
   for tag in tags:
     all_tags.append({
       'tag': tag,
       'count': Post.objects(tags=tag).count()
       })
   print all_tags
   return render_template('posts/list.html', posts = posts, tags = all_tags)
示例#2
0
文件: views.py 项目: phocode/myblog
 def get(self):
   user = User.objects.get(id=current_user.id)
   form = ProfileForm(obj=user)
   posts = Post.objects(author=current_user.id)
   return render_template('users/profile.html', 
       form=form,
       posts = posts,
       user = user,
       twitter_conn=social.twitter.get_connection(),
       facebook_conn=social.facebook.get_connection())
示例#3
0
文件: views.py 项目: phocode/myblog
 def get(self):
   posts = Post.objects(author=current_user.id)
   return render_template('users/personal.html', posts=posts)
示例#4
0
文件: views.py 项目: phocode/myblog
 def get(self, username):
   user = User.objects.get_or_404(username=username)
   posts = Post.objects(author=user.id)
   return render_template('users/user.html', user=user, posts=posts)