This application provides simple, extensible contact-form functionality for Django sites.
- Mail header 'From: "Your Name" <your@email.com>', so it's easy to reply to the sender.
- Subject provided by the user.
- Uses reCAPTCHA to block spam robots.
Requirements:
- Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0)
To use the contact_forms.forms.ReCaptchaContactForm form:
Install django-contact-form-recaptcha:
pip install django-contact-form-recaptcha
Obtain the reCAPTCHA API keys from https://www.google.com/recaptcha.
Supply the API keys for django-contact-form-recaptcha to use. You can either place them in the Django settings
RECAPTCHA_PUBLIC_KEY
andRECAPTCHA_PRIVATE_KEY
, or in the environment variablesPYTHON_RECAPTCHA_PUBLIC_KEY
andPYTHON_RECAPTCHA_PRIVATE_KEY
.Add the application
captcha
in the Django settings:INSTALLED_APPS = [ ... 'captcha', ]
Then use the following URLconf:
from django.conf.urls import include, url urlpatterns = [ # ... other URL patterns for your site ... url(r'^contact/', include('contact_form.recaptcha_urls')), ]
If you're using Django 2.0, you can do:
from django.urls import include, path urlpatterns = [ # ... other URL patterns for your site ... path('contact/', include('contact_form.recaptcha_urls')), ]
Create your templates in your
templates
directory:- contact_form/contact_form.html
- contact_form/contact_form_sent.html
- contact_form/contact_form.txt
- contact_form/contact_form_subject.txt
Or you can use the templates provided by this package. Remember to add the application
contact_form
in the Django settings.Emails are sent to the
MANAGERS
defined in your Django settings:MANAGERS = [('John', 'john@example.com'),]
Full documentation for all functionality is included and is also available online.
Originally forked from django-contact-form.