次のようなログイン ビューがあります。
def login_backend(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
state = "Username or Password Incorrect!"
if user is not None:
login(request, user)
return HttpResponseRedirect('/overview/')
else:
captcha = CaptchaField()
return render_to_response('login_backend.html', {'state':state,
'captcha':captcha }, context_instance=RequestContext(request))
else:
return render_to_response('login_backend.html', context_instance=RequestContext(request))
現在、ユーザーが複数回間違っている場合、キャプチャが表示されます。ただし、ユーザーが3回以上間違ったパスワードを入力した場合にのみキャプチャを表示したい. ユーザーの試行を追跡できると思いますattempt > 3
。キャプチャを表示できる場合は、それを実装する方法がわかりません。これどうやってするの?