Mercurial > public > sg101
comparison contact/forms.py @ 1173:a1a223ab0c8f
Improve form error message when missing captcha response
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Apr 2018 14:03:04 -0500 |
parents | b957e4829a03 |
children |
comparison
equal
deleted
inserted
replaced
1172:b957e4829a03 | 1173:a1a223ab0c8f |
---|---|
40 | 40 |
41 def clean(self): | 41 def clean(self): |
42 super(ContactForm, self).clean() | 42 super(ContactForm, self).clean() |
43 captcha_response = self.request.POST.get('g-recaptcha-response') | 43 captcha_response = self.request.POST.get('g-recaptcha-response') |
44 if not captcha_response: | 44 if not captcha_response: |
45 raise forms.ValidationError('Missing reCAPTCHA response') | 45 raise forms.ValidationError("Please verify you aren't a robot") |
46 r = requests.post(settings.RECAPTCHA_URL, data={ | 46 r = requests.post(settings.RECAPTCHA_URL, data={ |
47 'secret': settings.RECAPTCHA_SECRET_KEY, | 47 'secret': settings.RECAPTCHA_SECRET_KEY, |
48 'response': captcha_response, | 48 'response': captcha_response, |
49 'remoteip': get_ip(self.request), | 49 'remoteip': get_ip(self.request), |
50 }) | 50 }) |