Django context processor gets AnonymousUser

Posted by myfreeweb on Stack Overflow See other posts from Stack Overflow or by myfreeweb
Published on 2010-05-27T13:13:05Z Indexed on 2010/05/27 13:31 UTC
Read the original article Hit count: 227

Filed under:
|

instead of User.

def myview(request):   
    return render_to_response('tmpl.html', {'user': User.objects.get(id=1})

works fine and passes User to template. But

def myview(request):   
    return render_to_response('tmpl.html', {}, context_instance=RequestContext(request))

with a context processor

def user(request):
    from django.contrib.auth.models import User
    return {'user': User.objects.get(id=1)}

passes AnonymousUser, so I can't get the variables I need :( What's wrong?

© Stack Overflow or respective owner

Related posts about python

Related posts about django