tags:

views:

50

answers:

1

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 ?

+3  A: 

request.user has the logged-in user.

Ignacio Vazquez-Abrams
hi lg,look the updated,
zjm1126
`ps` is a `QuerySet`. QuerySets don't have a `name` attribute.
Ignacio Vazquez-Abrams
so i can use ps[0] yes ?
zjm1126
If you like. But why not use `.get()` in the first place?
Ignacio Vazquez-Abrams