Total Pageviews

Saturday, 14 June 2014

django-honeypot

Django application that provides utilities for preventing automated form spam.
Provides template tags, view decorators, and middleware to add and verify honeypot fields to forms.
django-honeypot is a project of Sunlight Labs (c) 2014. Written by James Turk <jturk@sunlightfoundation.com> with contributions by Flavio Curella and Daniel Greenfeld.
Source: http://github.com/sunlightlabs/django-honeypot/

Requirements

  • python >= 2.6
  • django >= 1.4
  • six

Usage

settings.py

Be sure to add honeypot to INSTALLED_APPS in settings.py.
You will almost always need to define HONEYPOT_FIELD_NAME which is the name to use for the honeypot field. Some sophisticated bots will attempt to avoid fields named honeypot, so it may be wise to name the field something slightly more realistic such as "phonenumber" or "body2".
HONEYPOT_VALUE is an option that you can specify to populate the honeypot field, by default the honeypot field will be empty and any text entered into it will result in a failed POST. HONEYPOT_VALUE can be a string or a callable that takes no arguments.
HONEYPOT_VERIFIER is an advanced option that you can specify to validate the honeypot. The default verifier ensures that the contents of the honeypot field matches HONEYPOT_VALUE. Using a combination of a callable for HONEYPOT_VALUE and HONEYPOT_VERIFIER it is possible to implement a more advanced technique such as using timestamps.

from https://github.com/sunlightlabs/django-honeypot