Mercurial > public > sg101
diff contact/views.py @ 1172:b957e4829a03
Add reCAPTCHA to contact form
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 14 Apr 2018 13:53:05 -0500 |
parents | 6ac56115e0a8 |
children |
line wrap: on
line diff
--- a/contact/views.py Mon Jan 01 10:39:48 2018 -0600 +++ b/contact/views.py Sat Apr 14 13:53:05 2018 -0500 @@ -1,5 +1,6 @@ """Views for the contact application.""" +from django.conf import settings from django.shortcuts import redirect, render from django.views.generic import TemplateView @@ -9,7 +10,7 @@ def contact_form(request): if request.method == 'POST': - form = ContactForm(request.POST) + form = ContactForm(request.POST, request=request) if form.is_valid(): form.save() return redirect('contact-thanks') @@ -26,10 +27,11 @@ if subject: initial_data['subject'] = subject - form = ContactForm(initial=initial_data) + form = ContactForm(initial=initial_data, request=request) return render(request, 'contact/contact_form.html', { 'form': form, + 'RECAPTCHA_SITE_KEY': settings.RECAPTCHA_SITE_KEY, 'V3_DESIGN': True, })