-
Notifications
You must be signed in to change notification settings - Fork 328
Open
Description
I added the captcha field in accordance with the instructions here. And the captcha field shows up in the custom form.
However, it allows me to the next url even if I have entered the wrong input to the captcha.
In the sense, it is not validating the captcha correctly. Can someone help me out? What am I doing wrong?
Here's the form :
class SomeForm(AuthenticationForm):
business = forms.ModelChoiceField(
queryset=Business.objects.all().order_by('bus_name'),
required=True,
empty_label="Select Business")
phone = forms.IntegerField(
label=" ",
widget=forms.TextInput(
attrs={
'class': 'form-control',
'style': 'width:300px',
'name': 'phone',
"min": "6666666666",
"max": "9999999999",
'placeholder': "Mobile number"
}))
password = forms.CharField(
label=" ",
max_length=30,
widget=forms.PasswordInput(
attrs={
'class': 'form-control',
'name': 'phone',
'style': 'width:300px',
'password': forms.PasswordInput(),
'placeholder': "Enter your password"
}))
captcha = CaptchaField()Here's the views.py :
def login(request):
form = SomeForm()
if request.method == 'POST':
captcha_form = SomeForm(request, request.POST)
if captcha_form.is_valid:
url = reverse('dashboard')
return HttpResponse(url)
else:
print('not valid form')Here's the input form on clicking submit :
request.POST:
<QueryDict: {'csrfmiddlewaretoken': ['some_token'], 'phone': ['999999999'], 'password': ['pass'], 'business': ['1'], 'captcha_0': ['f44cda7f7d14bfbaa76ba702cfa477a99b3d4160'], 'captcha_1': ['j']}>
the captcha form:
<tr><th><label for="id_phone"> :</label></th><td><input type="text" name="phone" value="9999999999" class="form-control" style="width:300px" name="phone" min="6666666666" max="9999999999" placeholder="Mobile number" required id="id_phone"></td></tr>
<tr><th><label for="id_password"> :</label></th><td><input type="password" name="password" class="form-control" name="phone" style="width:300px" password="<django.forms.widgets.PasswordInput object at 0x3fs822310>" placeholder="Enter your password" maxlength="30" required id="id_password"></td></tr>
<tr><th><label for="id_captcha_1">Captcha:</label></th><td><ul class="errorlist"><li>Invalid CAPTCHA</li></ul><img src="/auth/captcha/image/148bf605b02c87516ad088f7e43d5a6c41d04264/" alt="captcha" class="captcha" />
<input type="hidden" name="captcha_0" value="148bf605b02c87516ad088f7e43d5a6c41d04264" required id="id_captcha_0"><input type="text" name="captcha_1" required id="id_captcha_1" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false"><input type="hidden" name="organization" value="1" id="id_organization"></td></tr>
Metadata
Metadata
Assignees
Labels
No labels