django getting current user id

Posted by dana on Stack Overflow See other posts from Stack Overflow or by dana
Published on 2010-06-03T16:01:50Z Indexed on 2010/06/03 16:04 UTC
Read the original article Hit count: 262

Filed under:
|
|
|
|

hello, i have a mini app where users can login, view their profile, and follow each other. 'Follow' is a relation like a regular 'friend' relationship in virtual communities, but it is not necessarily reciprocal, meaning that one can follow a user, without the need that the user to be following back that person who follows him. my problem is: if i am a logged in user, and i navigate to a profile X, and push the button follow, how can i take the current profile id ?(current profile meaning the profile that I, the logged in user, am viewing right now.)

the view:

   def follow(request):
      if request.method == 'POST':
    form = FollowForm(request.POST)
    if form.is_valid():
    new_obj = form.save(commit=False)
    new_obj.initiated_by = request.user
    u = User.objects. what here?
    new_obj.follow = u   
    new_obj.save()
    return HttpResponseRedirect('.')    
   else:
       form = FollowForm()     
   return render_to_response('followme/follow.html', {
       'form': form,
       }, 
      context_instance=RequestContext(request))  

thanks in advance!

© Stack Overflow or respective owner

Related posts about django

Related posts about post