這是我如何定義我的USER_LOGIN取景功能錯誤_代碼:禁止(403)。 Python的Django的:當用戶登錄刷新頁面
def login_user(request):
if request.method == "POST":
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
albums = Album.objects.filter(user=request.user)
return render(request, 'violin/index.html', {'scale': scale})
else:
return render(request, 'music/login.html', {'error_message': 'Disabled account: Contact admin'})
else:
return render(request, 'violin/login.html', {'error_message': 'Invalid credentials'})
return render(request, 'violin/login.html')
Here is my code error: Forbidden (403)
登錄的用戶查看頁面時發生錯誤,但沒有登錄的用戶查看時發生錯誤?這似乎很奇怪,因爲GET請求將只執行最終的'render',這似乎完全不可知與登錄狀態有關。 –