Skip to main content

A contact form app for Django

Project description

django-envelope is a simple contact form app for Django web framework.

The application provides a simple contact form and a Django view to handle form submission.


Make sure you have Django installed. Then install the package from PyPI:

pip install django-envelope


easy_install django-envelope

This should download and install django-envelope, along with it’s dependencies (currently only django-honeypot).

If you like living on the edge, grab the development version from Github:

git clone git://
cd django-envelope
python install


Add envelope to your INSTALLED_APPS in The application does not define any models, so a syncdb is not needed.

For a quick start, simply include the app’s in your main URLconf, like this:

urlpatterns = patterns('',
    (r'^contact/',    include('envelope.urls')),

That’s basically it. Navigate to the given URL and see the contact form in action. See below for more customization options.


These values defined in affect the application:

  • DEFAULT_FROM_EMAIL: This is both the sender and the recipient of the email sent with your contact form. Some web servers do not allow sending messages from an address that is different than the one used for SMTP authentication.

  • ENVELOPE_CONTACT_CHOICES: A tuple of pairs describing possible choices for message type. The default is defined as follows:

        ('',    u"Choose"),
        (10,    u"A general question regarding the website"),
        (None,   u"Other"),

    The numeric values are pretty much arbitrary. Remember to leave an empty value for the choice when the field is initially unset (“Choose”).

  • ENVELOPE_SUBJECT_INTRO: The prefix for subject line of the email message. This is different than EMAIL_SUBJECT_PREFIX which is global for the whole project. ENVELOPE_SUBJECT_INTRO goes after the global prefix and is followed by the actual subject entered in the form by website’s user.

    Default value: Message from contact form:

  • ENVELOPE_MESSAGE_THANKS: A message sent to the user (using django.contrib.messages) after successful submission.

    Default value: Thank you for your message.

  • ENVELOPE_MESSAGE_ERROR: A message sent to the user (using django.contrib.messages) after an attempt to send an invalid form.

    Default value: There was en error in the contact form.


If you want some more fine-grained control over the contact form, you can supply additional optional arguments to the view function. Instead of including the application’s URLconf, hook the view into your The following optional arguments are recognized by the view function:

  • form_class: Which form class to use for contact message handling. The default (ContactForm) is often enough, but you can subclass it if you want, or even replace with a totally custom class. The only requirement is that your custom class has a send() method which should do… well, guess what. Stick to the default or its subclasses.

  • template_name: Full name of the template which will display the form. By default it is envelope/contact.html.

  • redirect_to: URL of the page with some kind of a “thank you for your feedback”, displayed after the form is successfully submitted. If left unset, the view redirects to itself.

  • extra_context: A dictionary of values to add to template context.


from my_app.forms import MyContactForm

contact_info = {
    'form_class':       MyContactForm,
    'template_name':    'my_contact.html',
    'redirect_to':      '/thanks/',
urlpatterns = patterns('',

To customize the email message sent to you, create a template called envelope/email_body.txt. You can use any of the ContactForm field names as template variables.


django-envelope is free software, licensed under the MIT/X11 License. A copy of the license is provided with the application in the LICENSE file.


Zbigniew Siciarz (antyqjon atty gmail dotty com)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (14.1 kB view hashes)

Uploaded Source

Built Distributions

django_envelope-0.1.4-py2.6.egg (10.4 kB view hashes)

Uploaded Source

django-envelope-0.1.4.win32.exe (208.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page