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?
Are you sure that your context processor is enabled in
TEMPLATE_CONTEXT_PROCESSORSin settings.py?More to the point, does it come before or after the built-in
django.contrib.auth.context_processors.auth? If it’s before, it will be overridden by that processor, which will redefineuseras the actual logged-in user, or AnonymousUser if none.