开发者

Django microblog showing a logged in user only his posts

I have a miniblog application, with a class named New (referring to a new post), having a foreign key to an user(who has posted the entry). above I have a method that displays all the posts from all the users.

I'开发者_如何学运维d like to show to the logged in user only his posts.

How can I do it?

def paginate(request):
  paginator = New.objects.all()
  return render_to_response('news/newform.html', {
    'object_list': paginator,

    }, 
    context_instance=RequestContext(request)) 


if request.user.is_authenticated():
   paginator = New.objects.filter(user=request.user)

(If you haven't already, it's worth checking out the Django Book)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜