zjm1126
zjm1126

Reputation: 66637

how to get the 'user' object in django

i want to get the user who login now ..

how to do this ..

thanks

this is my code :

ps=Position.objects.filter(name=User.username)

updated:

ps=Position.objects.filter(name=request.user.username)

and

return render_to_response(template_name, {
        "map_form": map_form,
        "map": map,
        "group": map, # @@@ this should be the only context var for the map
        "is_member": is_member,
        "ps":ps
    }, context_instance=RequestContext(request))

in the html:

var ps='{{ ps.name }}'
alert(ps)

and it does print nothing ?

why ?

Upvotes: 1

Views: 4603

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

request.user has the logged-in user.

Upvotes: 6

Related Questions