[Python-modules-commits] [python-django-contact-form] 01/10: Imported Upstream version 1.3

Andrew Starr-Bochicchio asb at moszumanska.debian.org
Sat Dec 24 20:43:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

asb pushed a commit to branch master
in repository python-django-contact-form.

commit c8a9b1fc1d10f72dc2692268fe73d0685da13213
Author: Andrew Starr-Bochicchio <a.starr.b at gmail.com>
Date:   Sat Dec 24 14:51:45 2016 -0500

    Imported Upstream version 1.3
---
 .gitignore               |   1 +
 .travis.yml              |  11 +++--
 LICENSE                  |   2 +-
 README.rst               |   4 +-
 contact_form/forms.py    |   5 +-
 contact_form/runtests.py |  29 ++++++++----
 contact_form/views.py    |   5 +-
 docs/conf.py             |   6 +--
 docs/faq.rst             |  56 ++++++++++++++++------
 docs/forms.rst           |  44 ++++++++---------
 docs/index.rst           |  34 ++++++++-----
 docs/install.rst         | 121 +++++++++++++----------------------------------
 docs/quickstart.rst      | 108 ++++++++++++++++++++++++++++++++++++++++++
 docs/views.rst           |  18 ++++++-
 setup.py                 |   3 +-
 15 files changed, 284 insertions(+), 163 deletions(-)

diff --git a/.gitignore b/.gitignore
index 462e3e6..955f665 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@
 __pycache__
 *.egg-info
 docs/_build/
+dist/
 .coverage
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index b1d7e0f..67dd0d4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,16 +6,19 @@ python:
  - "3.3"
  - "2.7"
 env:
- - DJANGO_VERSION=1.8.7
- - DJANGO_VERSION=1.9
+ - DJANGO_VERSION=1.8.16
+ - DJANGO_VERSION=1.9.11
+ - DJANGO_VERSION=1.10.3
 install:
  - pip install coverage>=4.0
  - pip install flake8
  - pip install -q Django==$DJANGO_VERSION
 matrix:
  exclude:
-  - python: "3.3"
-    env: DJANGO_VERSION=1.9
+   - python: "3.3"
+     env: DJANGO_VERSION=1.9.11
+   - python: "3.3"
+     env: DJANGO_VERSION=1.10.3
 script:
  - coverage run setup.py test
  - flake8 contact_form
diff --git a/LICENSE b/LICENSE
index f8c707b..5f67d07 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2015, James Bennett
+Copyright (c) 2007-2016, James Bennett
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/README.rst b/README.rst
index 0751b15..e7f5cdb 100644
--- a/README.rst
+++ b/README.rst
@@ -3,8 +3,8 @@
 .. image:: https://travis-ci.org/ubernostrum/django-contact-form.svg?branch=master
     :target: https://travis-ci.org/ubernostrum/django-contact-form
 
-This application provids simple, extensible contact-form functionality
+This application provides simple, extensible contact-form functionality
 for `Django <https://www.djangoproject.com/>`_ sites.
 
 Full documentation for all functionality is included and is also
-`available online <http://django-contact-form.readthedocs.org/>`_.
\ No newline at end of file
+`available online <http://django-contact-form.readthedocs.io/>`_.
\ No newline at end of file
diff --git a/contact_form/forms.py b/contact_form/forms.py
index d77d587..4506859 100644
--- a/contact_form/forms.py
+++ b/contact_form/forms.py
@@ -61,7 +61,10 @@ class ContactForm(forms.Form):
         Render the subject of the message to a string.
 
         """
-        subject = loader.render_to_string(self.subject_template_name,
+        template_name = self.subject_template_name() if \
+            callable(self.subject_template_name) \
+            else self.subject_template_name
+        subject = loader.render_to_string(template_name,
                                           self.get_context())
         return ''.join(subject.splitlines())
 
diff --git a/contact_form/runtests.py b/contact_form/runtests.py
index a2901e5..549e2db 100644
--- a/contact_form/runtests.py
+++ b/contact_form/runtests.py
@@ -12,15 +12,14 @@ import os
 import sys
 
 
-# Make sure django-contact-form is (at least temporarily) on the
-# import path.
-CONTACT_FORM_DIR = os.path.abspath(os.path.dirname(__file__))
-sys.path.insert(0, CONTACT_FORM_DIR)
+# Make sure the app is (at least temporarily) on the import path.
+APP_DIR = os.path.abspath(os.path.dirname(__file__))
+sys.path.insert(0, APP_DIR)
 
 
 # Minimum settings required for django-contact-form to work.
 SETTINGS_DICT = {
-    'BASE_DIR': CONTACT_FORM_DIR,
+    'BASE_DIR': APP_DIR,
     'INSTALLED_APPS': (
         'contact_form',
         'django.contrib.auth',
@@ -31,19 +30,31 @@ SETTINGS_DICT = {
     'DATABASES': {
         'default': {
             'ENGINE': 'django.db.backends.sqlite3',
-            'NAME': os.path.join(CONTACT_FORM_DIR, 'db.sqlite3'),
+            'NAME': os.path.join(APP_DIR, 'db.sqlite3'),
         },
     },
     'MIDDLEWARE_CLASSES': (
         'django.middleware.common.CommonMiddleware',
         'django.middleware.csrf.CsrfViewMiddleware',
     ),
-    'TEMPLATE_DIRS': (
-        os.path.join(CONTACT_FORM_DIR, 'tests/templates'),
-    ),
     'SITE_ID': 1,
     'DEFAULT_FROM_EMAIL': 'contact at example.com',
     'MANAGERS': [('Manager', 'noreply at example.com')],
+    'TEMPLATES': [{
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [os.path.join(APP_DIR, 'tests/templates')],
+        'OPTIONS': {
+            'context_processors': [
+                'django.contrib.auth.context_processors.auth',
+                'django.template.context_processors.debug',
+                'django.template.context_processors.i18n',
+                'django.template.context_processors.media',
+                'django.template.context_processors.static',
+                'django.template.context_processors.tz',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    }],
 }
 
 
diff --git a/contact_form/views.py b/contact_form/views.py
index 4115972..a06e967 100644
--- a/contact_form/views.py
+++ b/contact_form/views.py
@@ -34,8 +34,9 @@ class ContactFormView(FormView):
         # undesirable for performance reasons.
         #
         # Manually implementing this method, and passing the form
-        # instance to get_context_data(), solves this issue (which
-        # will be fixed in Django 1.9.1 and Django 1.10).
+        # instance to get_context_data(), solves this issue (which was
+        # fixed in Django 1.9.1 and will not be present in Django
+        # 1.10).
         return self.render_to_response(self.get_context_data(form=form))
 
     def get_form_kwargs(self):
diff --git a/docs/conf.py b/docs/conf.py
index 4d45081..a171844 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -7,9 +7,9 @@ templates_path = ['_templates']
 source_suffix = '.rst'
 master_doc = 'index'
 project = u'django-contact-form'
-copyright = u'2007-2015, James Bennett'
-version = '1.2'
-release = '1.2'
+copyright = u'2007-2016, James Bennett'
+xversion = '1.3'
+release = '1.3'
 exclude_trees = ['_build']
 pygments_style = 'sphinx'
 html_static_path = ['_static']
diff --git a/docs/faq.rst b/docs/faq.rst
index 32d9fe8..be9dbd2 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -5,20 +5,32 @@ Frequently asked questions
 ==========================
 
 The following notes answer some common questions, and may be useful to
-you when installing, configuring or using ``django-contact-form``.
+you when installing, configuring or using django-contact-form.
 
 
-What versions of Django are supported?
---------------------------------------
+What versions of Django and Python are supported?
+-------------------------------------------------
+
+As of django-contact-form |version|, Django 1.8, 1.9, and 1.10 are
+supported, on Python 2.7, 3.3, 3.4 or 3.5. Although Django 1.8
+supported Python 3.2 at initial release, Python 3.2 is now at its
+end-of-life and django-contact-form no longer supports it.
 
-As of ``django-contact-form`` |version|, Django 1.8 and 1.9 are supported.
+It is expected that django-contact-form |version| will also work
+without modification on Python 3.6 once it is released.
 
 
-What versions of Python are supported?
---------------------------------------
+What license is django-contact-form under?
+----------------------------------------------
 
-As of |version|, ``django-contact-form`` supports Python 2.7, 3.3, 3.4, and
-3.5.
+django-contact-form is offered under a three-clause BSD-style
+license; this is `an OSI-approved open-source license
+<http://www.opensource.org/licenses/bsd-license.php>`_, and allows you
+a large degree of freedom in modifiying and redistributing the
+code. For the full terms, see the file ``LICENSE`` which came with
+your copy of django-contact-form; if you did not receive a copy of
+this file, you can view it online at
+<https://github.com/ubernostrum/django-contact-form/blob/master/LICENSE>.
 
 
 Why aren't there any default templates I can use?
@@ -27,7 +39,7 @@ Why aren't there any default templates I can use?
 Usable default templates, for an application designed to be widely
 reused, are essentially impossible to produce; variations in site
 design, block structure, etc. cannot be reliably accounted for. As
-such, ``django-contact-form`` provides bare-bones (i.e., containing no
+such, django-contact-form provides bare-bones (i.e., containing no
 HTML structure whatsoever) templates in its source distribution to
 enable running tests, and otherwise simply provides good documentation
 of all required templates and the context made available to them.
@@ -36,18 +48,18 @@ of all required templates and the context made available to them.
 What happened to the spam-filtering form in previous versions?
 --------------------------------------------------------------
 
-Older versions of ``django-contact-form`` shipped a subclass of
+Older versions of django-contact-form shipped a subclass of
 :class:`~contact_form.forms.ContactForm` which used `the Akismet web
 service <http://akismet.com/>`_ to identify and reject spam
 submissions.
 
 Unfortunately, the Akismet Python library -- required in order to use
 such a class -- does not currently support all versions of Python on
-which ``django-contact-form`` is supported, meaning it cannot be
-included in ``django-contact-form`` by default. The author of
-``django-contact-form`` is working on producing a version of the
+which django-contact-form is supported, meaning it cannot be
+included in django-contact-form by default. The author of
+django-contact-form is working on producing a version of the
 Akismet library compatible with Python 3, but it was not yet ready as
-of the release of ``django-contact-form`` |version|.
+of the release of django-contact-form |version|.
 
 
 Why am I getting a bunch of ``BadHeaderError`` exceptions?
@@ -70,3 +82,19 @@ is the exception Django raises when a newline is detected in a header.
 
 Note that this only applies to the headers of an email message; the
 message body can (and usually does) contain newlines.
+
+
+I found a bug or want to make an improvement!
+---------------------------------------------
+
+The canonical development repository for django-contact-form is
+online at <https://github.com/ubernostrum/django-contact-form>. Issues
+and pull requests can both be filed there.
+
+If you'd like to contribute to django-contact-form, that's great!
+Just please remember that pull requests should include tests and
+documentation for any changes made, and that following `PEP 8
+<https://www.python.org/dev/peps/pep-0008/>`_ is mandatory. Pull
+requests without documentation won't be merged, and PEP 8 style
+violations or test coverage below 100% are both configured to break
+the build.
diff --git a/docs/forms.rst b/docs/forms.rst
index 1f12212..9d34e93 100644
--- a/docs/forms.rst
+++ b/docs/forms.rst
@@ -10,9 +10,9 @@ The ContactForm class
     The base contact form class from which all contact form classes
     should inherit.
 
-    If you don't need any custom functionality, you can simply use
-    this form to provide basic contact functionality; it will collect
-    name, email address and message.
+    If you don't need any customization, you can simply use this form
+    to provide basic contact functionality; it will collect name,
+    email address and message.
 
     The :class:`~contact_form.views.ContactFormView` included in this
     application knows how to work with this form and can handle many
@@ -22,42 +22,38 @@ The ContactForm class
     of your own views, just do the following:
 
     1. When you instantiate the form, pass the current ``HttpRequest``
-       object to the constructor as the keyword argument ``request``;
-       this is used internally by the base implementation, and also
-       made available so that subclasses can add functionality which
-       relies on inspecting the request (such as spam filtering).
+       object as the keyword argument ``request``; this is used
+       internally by the base implementation, and also made available
+       so that subclasses can add functionality which relies on
+       inspecting the request (such as spam filtering).
 
     2. To send the message, call the form's ``save`` method, which
        accepts the keyword argument ``fail_silently`` and defaults it
-       to ``False``. This argument is passed directly to
-       ``send_mail``, and allows you to suppress or raise exceptions
-       as needed for debugging. The ``save`` method has no return
-       value.
+       to ``False``. This argument is passed directly to Django's
+       ``send_mail()`` function, and allows you to suppress or raise
+       exceptions as needed for debugging. The ``save`` method has no
+       return value.
 
     Other than that, treat it like any other form; validity checks and
-    validated data are handled normally, through the ``is_valid``
+    validated data are handled normally, through the ``is_valid()``
     method and the ``cleaned_data`` dictionary.
 
     Under the hood, this form uses a somewhat abstracted interface in
     order to make it easier to subclass and add functionality.
 
-    These attributes play a role in determining behavior:
+    The following attributes play a role in determining behavior, and
+    any of them can be implemented as an attribute or as a method:
 
     .. attribute:: from_email
 
        The email address to use in the ``From:`` header of the
-       message. This can also be implemented as a method named
-       ``from_email()``, in which case it will be called when
-       constructing the message. By default, this is the value of the
-       setting ``DEFAULT_FROM_EMAIL``.
+       message. By default, this is the value of the setting
+       ``DEFAULT_FROM_EMAIL``.
 
     .. attribute:: recipient_list
 
-       The list of recipients for the message. This can also be
-       implemented as a method named ``recipient_list()``, in which
-       case it will be called when constructing the message. By
-       default, this is the email addresses specified in the setting
-       ``MANAGERS``.
+       The list of recipients for the message. By default, this is the
+       email addresses specified in the setting ``MANAGERS``.
 
     .. attribute:: subject_template_name
 
@@ -96,7 +92,9 @@ The ContactForm class
        corresponding to the arguments to Django's ``send_mail``
        function, then returns the dictionary. Overriding this allows
        essentially unlimited customization of how the message is
-       generated.
+       generated. Note that for compatibility, implementations which
+       override this should support callables for the values of
+       ``from_email`` and ``recipient_list``.
 
     .. method:: get_context()
 
diff --git a/docs/index.rst b/docs/index.rst
index 8bb975c..d98c031 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,31 +1,41 @@
 django-contact-form |version|
 =============================
 
-Providing some sort of contact or feedback form for soliciting
-information from site visitors is a common need in web development,
-and writing a contact form and associated handler view, while
-relatively straightforward to do with `Django
-<https://www.djangoproject.com/>`_, can be a tedious and repetitive
-task.
+``django-contact-form`` provides simple, customizable contact-form
+functionality for `Django <https://www.djangoproject.com/>`_-powered
+Web sites.
 
-This application aims to remove or reduce that tedium and repetition
-by providing simple, extensible contact-form functionality for
-Django-powered sites.
-
-In the simplest case, all that's required is a bit of configuration
-and a few templates, and one pattern in your URLConf:
+Basic functionality (collecting a name, email address and message) can
+be achieved out of the box by setting up a few templates and adding
+one line to your site's root URLconf:
 
 .. code-block:: python
 
     url(r'^contact/', include('contact_form.urls')),
 
+For notes on getting started quickly, and on how to customize
+``django-contact-form``'s behavior, read through the full
+documentation below.
+
 
 Contents:
 
 .. toctree::
+   :caption: Installation and configuration
    :maxdepth: 1
 
    install
+   quickstart
+
+.. toctree::
+   :caption: For developers
+   :maxdepth: 1
+
    forms
    views
+
+.. toctree::
+   :caption: Other documentation
+   :maxdepth: 1
+
    faq
\ No newline at end of file
diff --git a/docs/install.rst b/docs/install.rst
index 8898a3c..57120fb 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -4,24 +4,41 @@
 Installation guide
 ==================
 
-Before installing ``django-contact-form``, you'll need to have a copy
+Before installing django-contact-form, you'll need to have a copy
 of `Django <https://www.djangoproject.com>`_ already installed. For
 information on obtaining and installing Django, consult the `Django
 download page <https://www.djangoproject.com/download/>`_, which
 offers convenient packaged downloads and installation instructions.
 
-The |version| release of ``django-contact-form`` supports Django 1.8 and 1.9,
-on any of Python 2.7, 3.3, 3.4, or 3.5. Older versions of Django and/or Python
-may work, but are not tested or officially supported.
+The |version| release of django-contact-form supports Django 1.8,
+1.9, and 1.10, on the following Python versions:
+
+* Django 1.8 suports Python 2.7, 3.3, 3.4 and 3.5.
+
+* Django 1.9 supports Python 2.7, 3.4 and 3.5.
+
+* Django 1.10 supports Python 2.7, 3.4 and 3.5.
+
+It is expected that django-contact-form |version| will work
+without modification on Python 3.6 once it is released.
+
+.. important:: **Python 3.2**
+
+   Although Django 1.8 supported Python 3.2 at the time of its
+   release, the Python 3.2 series has reached end-of-life, and as a
+   result support for Python 3.2 has been dropped from
+   django-contact-form.
 
 
 Normal installation
 -------------------
 
-The preferred method of installing ``django-contact-form`` is via
-``pip``, the standard Python package-installation tool. If you don't
-have ``pip``, instructions are available for `how to obtain and
-install it <https://pip.pypa.io/en/latest/installing.html>`_.
+The preferred method of installing django-contact-form is via ``pip``,
+the standard Python package-installation tool. If you don't have
+``pip``, instructions are available for `how to obtain and install it
+<https://pip.pypa.io/en/latest/installing.html>`_. If you're using
+Python 2.7.9 or later (for Python 2) or Python 3.4 or later (for
+Python 3), ``pip`` came bundled with your installation of Python.
 
 Once you have ``pip``, simply type::
 
@@ -31,7 +48,7 @@ Once you have ``pip``, simply type::
 Manual installation
 -------------------
 
-It's also possible to install ``django-contact-form`` manually. To do
+It's also possible to install django-contact-form manually. To do
 so, obtain the latest packaged version from `the listing on the Python
 Package Index
 <https://pypi.python.org/pypi/django-contact-form/>`_. Unpack the
@@ -39,21 +56,21 @@ Package Index
 
     python setup.py install
 
-Once you've installed ``django-contact-form``, you can verify
+Once you've installed django-contact-form, you can verify
 successful installation by opening a Python interpreter and typing
 ``import contact_form``.
 
 If the installation was successful, you'll simply get a fresh Python
 prompt. If you instead see an ``ImportError``, check the configuration
 of your install tools and your Python import path to ensure
-``django-contact-form`` installed into a location Python can import
+django-contact-form installed into a location Python can import
 from.
 
 
 Installing from a source checkout
 ---------------------------------
 
-The development repository for ``django-contact-form`` is at
+The development repository for django-contact-form is at
 <https://github.com/ubernostrum/django-contact-form>. Presuming you
 have `git <http://git-scm.com/>`_ installed, you can obtain a copy of
 the repository by typing::
@@ -67,80 +84,6 @@ revision you want, and install it using ``python setup.py install``.
 Basic configuration and use
 ---------------------------
 
-Once installed, only a small amount of setup is required to use
-``django-contact-form``. First, you'll need to make sure you've
-specified the appropriate settings for `Django to send email
-<https://docs.djangoproject.com/en/dev/topics/email/>`_. Most
-commonly, this will be ``EMAIL_HOST``, ``EMAIL_PORT``,
-``EMAIL_HOST_USER`` and ``EMAIL_HOST_PASSWORD``.
-
-You'll also want to make sure ``django-contact-form`` sends mail from
-the correct address, and sends to the correct address(es). Two
-standard Django settings control this:
-
-* By default, the ``From:`` header of all emails sent by
-  ``django-contact-form`` will be whatever email address is specified
-  in ``DEFAULT_FROM_EMAIL``.
-
-* By default, the recipient list for emails sent by
-  ``django-contact-form`` will be the email addresses specified in
-  ``MANAGERS``.
-
-If you'd prefer something else, this behavior is configurable; see
-:ref:`the form documentation <forms>` for details on how to customize
-the email addresses used.
-
-
-Templates
-~~~~~~~~~
-
-The following templates are required by the default setup of
-``django-contact-form``, so you'll need to create them:
-
-* ``contact_form/contact_form.html`` is the template which actually
-  renders the contact form. Important context variables are:
-
-  ``form``
-    The contact form instance.
-
-* ``contact_form/contact_form_sent.html`` is the template rendered
-  after a message is successfully sent through the contact form. It
-  has no specific context variables, beyond whatever's supplied by the
-  context processors in use on your site.
-
-Additionally, the generated email makes use of two templates:
-``contact_form/contact_form_subject.txt`` will be rendered to obtain
-the subject line, and ``contact_form/contact_form.txt`` will be
-rendered to obtain the body of the email. These templates use
-``RequestContext``, so any context processors will be applied, and
-have the following additional context:
-
-``site``
-    The current site. Either a ``Site`` instance if
-    ``django.contrib.sites`` is installed, or a ``RequestSite``
-    instance if not.
-
-``body``
-    The body of the message the user entered into the contact form.
-
-``email``
-    The email address the user supplied to the contact form.
-
-``name``
-    The name the user supplied to the contact form.
-
-
-URL configuration
-~~~~~~~~~~~~~~~~~
-
-Once you've got settings and templates set up, all that's left is to
-configure your URLs to point to the ``django-contact-form`` views. A
-URLconf -- ``contact_form.urls`` -- is provided with
-``django-contact-form``, which will wire up these views with default
-behavior; to make use of it, simply include it at whatever point in
-your URL hierarchy you'd like your contact form to live. For example,
-to place it at ``/contact/``:
-
-.. code-block:: python
-
-    url(r'^contact/', include('contact_form.urls')),
+Once you have Django and django-contact-form installed, check out
+:ref:`the quick start guide <quickstart>` to see how to get your
+contact form up and running.
\ No newline at end of file
diff --git a/docs/quickstart.rst b/docs/quickstart.rst
new file mode 100644
index 0000000..0453f77
--- /dev/null
+++ b/docs/quickstart.rst
@@ -0,0 +1,108 @@
+.. _quickstart:
+
+Quick start guide
+=================
+
+First you'll need to have Django and django-contact-form
+installed; for details on that, see :ref:`the installation guide
+<install>`.
+
+Once that's done, you can start setting up
+django-contact-form. Since it doesn't provide any database models
+or use any other application-config mechanisms, you do *not* need to
+add django-contact-form to your ``INSTALLED_APPS`` setting; you
+can simply begin using it right away.
+
+
+URL configuration
+=================
+
+The easiest way to set up the views in django-contact-form is to
+just use the provided URLconf, found at ``contact_form.urls``. You can
+include it wherever you like in your site's URL configuration; for
+example, to have it live at the URL ``/contact/``:
+
+.. code-block:: python
+
+    from django.conf.urls import include, url
+
+
+    urlpatterns = [
+        # ... other URL patterns for your site ...
+        url(r'^contact/', include('contact_form.urls')),
+    ]
+
+If you'll be using a custom form class, you'll need to manually set up
+your URLs so you can tell django-contact-form about your form
+class. For example:
+
+
+.. code-block:: python
+
+    from django.conf.urls import include, url
+    from django.views.generic import TemplateView
+
+    from contact_form.views import ContactFormView
+
+    from yourapp.forms import YourCustomFormClass
+
+
+    urlpatterns = [
+        # ... other URL patterns for your site ...
+        url(r'^contact/$',
+            ContactFormView.as_view(
+                form_class=YourCustomFormClass),
+            name='contact_form'),
+        url(r'^contact/sent/$',
+            TemplateView.as_view(
+                template_name='contact_form/contact_form_sent.html'),
+            name='contact_form_sent'),
+    ]
+
+.. important:: **Where to put custom forms and views**
+
+   When writing a custom form class (or custom ``ContactFormView``
+   subclass), **don't** put your custom code inside
+   django-contact-form. Instead, put your custom code in the
+   appropriate place (a ``forms.py`` or ``views.py`` file) in an
+   application you've written.
+
+
+Required templates
+==================
+
+The two views above will need two templates to be created:
+
+``contact_form/contact_form.html``
+    This is used to display the contact form. It has a
+    ``RequestContext`` (so any context processors will be applied),
+    and also provides the form instance as the context variable
+    ``form``.
+
+``contact_form/contact_form_sent.html``
+    This is used after a successful form submission, to let the user
+    know their message has been sent. It has a ``RequestContext``, but
+    provides no additional context variables of its own.
+
+You'll also need to create at least two more templates to handle the
+rendering of the message: ``contact_form/contact_form_subject.txt``
+for the subject line of the email to send, and
+``contact_form/contact_form.txt`` for the body (note that the file
+extension for these is ``.txt``, not ``.html``!). Both of these will
+receive a ``RequestContext`` with a set of variables named for the
+fields of the form (by default: ``name``, ``email`` and ``body``), as
+well as one more variable: ``site``, representing the current site
+(either a ``Site`` or ``RequestSite`` instance, depending on whether
+Django's sites framework is installed).
+
+.. warning:: **Subject must be a single line**
+
+   In order to prevent `header injection attacks
+   <https://en.wikipedia.org/wiki/Email_injection>`_, the subject
+   *must* be only a single line of text, and Django's email framework
+   will reject any attempt to send an email with a multi-line
+   subject. So it's a good idea to ensure your
+   ``contact_form_subject.txt`` template only produces a single line
+   of output when rendered; as a precaution, however,
+   django-contact-form will split the output of this template at
+   line breaks, then forcibly re-join it into a single line of text.
diff --git a/docs/views.rst b/docs/views.rst
index f5d25b4..5153318 100644
--- a/docs/views.rst
+++ b/docs/views.rst
@@ -29,7 +29,10 @@ Built-in views
        form.
 
     Additionally, the following standard (from ``FormView``) methods
-    and attributes are commonly useful to override:
+    and attributes are commonly useful to override (all attributes
+    below can also be passed to ``as_view()`` in the URLconf,
+    permitting customization without the need to write a full custom
+    subclass of ``ContactFormView``):
 
     .. attribute:: form_class
 
@@ -48,7 +51,7 @@ Built-in views
 
        The URL to redirect to after successful form submission. By
        default, this is the named URL ``contact_form.sent``. In the
-       default URLconf provided with ``django-contact-form``, that URL
+       default URLconf provided with django-contact-form, that URL
        is mapped to ``TemplateView`` rendering the template
        ``contact_form/contact_form_sent.html``.
 
@@ -69,3 +72,14 @@ Built-in views
           approach is to use ``super()`` to call the base
           implementation in ``ContactFormView``, and modify the
           dictionary it returns.
+
+    .. warning:: Implementing ``form_invalid()``
+
+       To work around `a potential performance issue in Django 1.9
+       <https://code.djangoproject.com/ticket/25548>`_,
+       ``ContactFormView`` implements the ``form_invalid()``
+       method. If you choose to override ``form_invalid()`` in a
+       subclass of ``ContactFormView``, be sure to read the
+       implementation and comments in the source code of
+       django-contact-form first. Note that Django 1.9.1, once
+       released, will not be affected by this bug.
\ No newline at end of file
diff --git a/setup.py b/setup.py
index ab3178e..1deb43d 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup
 
 
 setup(name='django-contact-form',
-      version='1.2',
+      version='1.3',
       zip_safe=False, # eggs are the devil.
       description='Generic contact-form application for Django',
       long_description=open(os.path.join(os.path.dirname(__file__),
@@ -19,6 +19,7 @@ setup(name='django-contact-form',
                    'Framework :: Django',
                    'Framework :: Django :: 1.8',
                    'Framework :: Django :: 1.9',
+                   'Framework :: Django :: 1.10',
                    'Intended Audience :: Developers',
                    'License :: OSI Approved :: BSD License',
                    'Operating System :: OS Independent',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-contact-form.git



More information about the Python-modules-commits mailing list