Skip to main content

Provides protection against spammers and scammers.

Project description

Travis CI Status

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software.



Provides protection against spammers and scammers.


Install using pip pip install django-secureform

Then install the application into your Django project in There are also optional settings which will affect the behavior of SecureForm instances.

INSTALLED_APPS += ('django_secureform', )

# If you wish to use an encryption key other than Django's SECRET_KEY
SECUREFORM_CRYPT_KEY = 'super-secret encryption key'

# This is the name of the hidden field added to the form to contain
# security data.

# The number of seconds allowed between form rendering and submittal.

# The number of honeypot fields added to the form.

# By default, jQuery is needed to hide honeypots. If you already
# use jQuery in your app, you can disable this feature (preventing
# a duplicate script reference to jQuery).


from django_secureform.forms import SecureForm

# Define your form class as usual.
class MySecureForm(SecureForm):
    class Meta:
        # Override options in for this class.
        include_jquery = False

    name = forms.CharField()

Unit Testing

If you want to write unit tests for forms that derive from SecureForm, you will need to let this application know you are testing. SecureForm looks for settings.TESTING to evaluate to True. If so, it disables the security allowing the Django test client to send POST data using the original field names.

In the future, I would rather provide tools so that testing can happen with security enabled, but this is a quick workaround. Our test framework uses an environment variable to set settings.TESTING. For example, in…

import os

TESTING = True if 'TESTING' in os.environ else False

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

django-secureform-0.3-1.tar.gz (6.8 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