changeset 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 ba3230aba90c
files contact/forms.py sg101/templates/contact/contact_form.html
diffstat 2 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contact/forms.py	Sat Apr 14 13:53:05 2018 -0500
+++ b/contact/forms.py	Sat Apr 14 14:03:04 2018 -0500
@@ -42,7 +42,7 @@
         super(ContactForm, self).clean()
         captcha_response = self.request.POST.get('g-recaptcha-response')
         if not captcha_response:
-            raise forms.ValidationError('Missing reCAPTCHA response')
+            raise forms.ValidationError("Please verify you aren't a robot")
         r = requests.post(settings.RECAPTCHA_URL, data={
                 'secret': settings.RECAPTCHA_SECRET_KEY,
                 'response': captcha_response,
--- a/sg101/templates/contact/contact_form.html	Sat Apr 14 13:53:05 2018 -0500
+++ b/sg101/templates/contact/contact_form.html	Sat Apr 14 14:03:04 2018 -0500
@@ -10,6 +10,7 @@
 </p>
 
 <form action="{% url 'contact-form' %}" method="post">{% csrf_token %}
+   {{ form.non_field_errors }}
    <div class="row">
       <div class="small-12 medium-8 columns">
          <label>{{ form.name.label }}