django-honeypot
raw JSON → 1.3.0 verified Fri May 01 auth: no python
A Django application that provides honeypot field utilities for protecting forms against spam bots without requiring CAPTCHAs. Current version 1.3.0 supports Python >=3.12 and Django 4.x/5.x. Released irregularly.
pip install django-honeypot Common errors
error AttributeError: module 'honeypot' has no attribute 'HoneypotField' ↓
cause Importing directly from 'honeypot' instead of 'honeypot.fields'.
fix
Use: from honeypot.fields import HoneypotField
error django.core.exceptions.ImproperlyConfigured: The HONEYPOT_FIELD_NAME setting must be set. ↓
cause Missing HONEYPOT_FIELD_NAME in settings when using 'verify_honeypot_value' without specifying field_name argument.
fix
Add HONEYPOT_FIELD_NAME = 'hp' to settings.py or pass field_name='hp' to the decorator.
error TypeError: verify_honeypot_value() got an unexpected keyword argument 'field_name' ↓
cause Using old version (<1.3.0) where the decorator did not accept field_name parameter.
fix
Upgrade to django-honeypot >=1.3.0 or use the deprecated honeypot_equals.
Warnings
gotcha HoneypotField must be rendered in the template exactly once per form. If omitted or rendered multiple times, the decorator may still pass silently unless the field name is missing. ↓
fix Ensure the template includes the honeypot field (e.g., {{ form.hp }}) and does not include it more than once.
gotcha The decorator verify_honeypot_value does not check for honeypot presence if the request method is not POST. It only validates on POST requests. ↓
fix Use the decorator only on views that handle POST requests or add method checking in the view logic.
deprecated The 'honeypot_equals' decorator is deprecated in favor of 'verify_honeypot_value' with more flexible configuration. ↓
fix Replace honeypot_equals with verify_honeypot_value decorator.
Imports
- HoneypotField
from honeypot.fields import HoneypotField - honeypot_equals
from honeypot.decorators import honeypot_equals - verify_honeypot_value
from honeypot.decorators import verify_honeypot_value
Quickstart
# In settings.py
INSTALLED_APPS = [
...
'honeypot',
]
# In a form
from honeypot.fields import HoneypotField
class MyForm(forms.Form):
name = forms.CharField()
email = forms.EmailField()
hp = HoneypotField()
# In a view with decorator
from honeypot.decorators import verify_honeypot_value
from django.shortcuts import render
@verify_honeypot_value(field_name='hp')
def my_view(request):
# process form
return render(request, 'form.html', {'form': MyForm()})
# In template, render honeypot field
{{ form.hp }}