Answer the question
In order to leave comments, you need to log in
How to connect recaptcha2 to django?
Installed the application https://github.com/kbytesys/django-recaptcha2
Set up on the docks. Added my form:
from recaptcha2.fields import ReCaptchaField
from recaptcha2.widgets import ReCaptchaWidget
class CaptchaForm(forms.Form):
captcha = ReCaptchaField(
widget=ReCaptchaWidget(),
label='',
)
if request.POST:
auth_form = AuthForm(request, request.POST)
captcha_form = CaptchaForm(request, request.POST)
username = request.POST.get('username')
password = request.POST.get('password')
user = auth.authenticate(username=username, password=password)
# if user is not None and auth_form.is_valid():
if captcha_form.is_valid():
auth.login(request, user)
return HttpResponseRedirect('/')
else:
context['login_error'] = True
return render(request, 'index.html', context)
else:
return render(request, 'index.html', context)
captcha_form.is_valid()
gives an error:AttributeError at /auth/
'WSGIRequest' object has no attribute 'get'
Answer the question
In order to leave comments, you need to log in
You don't need to do so
#
username = request.POST.get('username')
password = request.POST.get('password')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question