私はClass-based view
Django で使用しています: 3 回後にのみキャプチャを表示し、表示された後にのみキャプチャを処理したいと考えています。今まで、1 回間違えた後にのみキャプチャを表示できます。
def post(self, request):
response = captcha.submit(
request.POST.get('recaptcha_challenge_field'),
request.POST.get('recaptcha_response_field'),
'[[ MY PRIVATE KEY ]]',
request.META['REMOTE_ADDR'],)
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
state = "The username or password is incorrect."
if user is not None:
login(request, user)
return HttpResponseRedirect('/index/')
else:
#captcha = CaptchaField()
public_key = settings.RECAPTCHA_PUBLIC_KEY
script = displayhtml(public_key=public_key)
return render_to_response('index.html', {'state':state, 'captcha':'captcha', 'script':script}, context_instance=RequestContext(request))
3 回後にキャプチャを表示し、response.is_valid を使用して処理したいと考えています。これどうやってするの?