Задать вопрос

Тел: +7 965 3737 888





Honeypot Field

<p>Simple anti-spam field which will cause the form to raise a ValidationError if the value in this field changes. Displays as a CSS hidden &lt;input type="text" /&gt; field.</p>
<p>If you specify a class in the attrs of the widget, the default style="display:none;" won't be rendered with the widget so that you can use a predefined CSS style to do your hiding instead. You can also cause the widget to be wrapped in an html comment to ensure it is not visible to the end user:</p>
class EmailForm(Form):
    email = EmailField()
    website = HoneypotField(widget=HoneypotWidget(
                      attrs={'class':'fish'}, html_comment=True))

Вопрос полезен? Да0/Нет0

Ответы (5):

Ответ полезен? Да0/Нет0

I see how it works--cool!

Ответ полезен? Да0/Нет0

This works for django 1.2 if you switch the import line to: from django.forms import *

However, you still can't use it with ModelForms.

Ответ полезен? Да0/Нет0

Sorry for my english, I'm catalan,

I have had an idea, but my experience with Django is little for develop myself.

The principle is use a system of human verification with a image digits or any type of question/response.

In a middleware, this load a system of question/response (base class), and put into context of template a variable form for print with a question and response inside anything [HTML_REMOVED][HTML_REMOVED].

When the user post a form with his data and response verification, the middleware load response and question and send it to system question/response for validate the post data. Another form is use a decorator before view function for validate the response. Or use this as a simple function inside de view. (It can be configurable)

The limitation is that every time the middleware create a question/response and in a system with an image letters this can consume more time for create an image for question (except this use a set of know questions).

The advantage are: This can be tranparent to forms, views and models, and only afect to templates and view decorators. Other developers can write his systems question/response for adapt with his project.

Ответ полезен? Да0/Нет0

You add the field(s) to an existing form.

I called the field "name" because it's a common field which bots would probably try and change, it won't show up visually in the form.

I wouldn't rely on this solely as a method of stopping spam, but it could help reduce it.

Ответ полезен? Да0/Нет0

This method of anti-spam seems intriguing, but I'm not sure that I am wrapping my head around it correctly.

Is this a field that you would add to an existing form to reduce fraudulent submissions of that form, or is it a field which you should create an entirely new and inactive form for, with the goal of attracting spam bots?

Also, in your example in your comments of the snippet, you have a name field as a HoneypotField. Does this suggest that the HoneypotField can be used to get input and not just thwart bots? I'm sure that there's just something that I'm missing, and if you could clarify that, I would be thankful because I need some anti-spam solutions soon myself!