djangoサイトのユーザー認証に問題があります。動作しているように見えるログイン画面があります。ユーザーがログインをクリックすると、に電話をかけますが、django.contrib.auth.login
正常に機能しているようです。ただし、後続のページでは、ユーザーがログインしていることを認識していません。例 {% user.is_authenticated %}
は誤りです。my-account
やなど、ログインしているユーザーが利用できるようにしたいメニュー機能もいくつかありますlogout
。これらの機能は、ログインページ以外ではご利用いただけません。これは本当に奇妙です。
これはユーザーコンテキストの問題のようです。しかし、ログインが安定していることを確認するために、どのようにコンテキストを渡すことになっているのかわかりません。 Does anyone know at could be going on here? Any advice?
---------base.htmlの一部------------
<!--- The following doesn't register even though I know I'm authenticated -->
{% if user.is_authenticated %}
<div id="menu">
<ul>
<li><a href="/clist">My Customers</a></li>
<li><a href="#">Customer Actions</a></li>
<li><a href="#">My Account</a></li>
</ul>
</div>
{% endif %}
--------- my views.py -----------------
# Should I be doing something to pass the user context here
def customer_list(request):
customer_list = Customer.objects.all().order_by('lastName')[:5]
c = Context({
'customer_list': customer_list,
})
t = loader.get_template(template)
return HttpResponse(t.render(cxt))