テンプレートにユーザー情報が含まれていないようです。あなた'django.contrib.auth.middleware.AuthenticationMiddleware'
はあなたのMIDDLEWARE_CLASSES
設定で必要であり、あなたのテンプレートの文脈でその良さを得るために、あなたはする必要があります:
from django.shortcuts import render_to_response
from django.template import RequestContext
def my_view(request):
return render_to_response('my_template.html',
my_data_dictionary,
context_instance=RequestContext(request))
どこでもこれを行う手間を省くために、の代わりにdjango-annoyingの render_to
デコレータを使用することを検討してくださいrender_to_response
。
@render_to('template.html')
def foo(request):
bar = Bar.object.all()
return {'bar': bar}
# equals to
def foo(request):
bar = Bar.object.all()
return render_to_response('template.html',
{'bar': bar},
context_instance=RequestContext(request))