定制Django.contrib.comments蜜罐

定制Django.contrib.comments蜜罐,django,django-comments,honeypot,Django,Django Comments,Honeypot,我正在使用Django的标准评论系统,我想扩展它的反垃圾邮件蜜罐功能 我考虑将字段的默认“name”和“id”更改为对垃圾邮件机器人更具吸引力的内容,例如“website”。我检查了html,如下所示: <p style="display:none;"> <label for="id_honeypot">Never send a human to do a machine's job</label> <input type="text"

我正在使用Django的标准评论系统,我想扩展它的反垃圾邮件蜜罐功能

我考虑将字段的默认“name”和“id”更改为对垃圾邮件机器人更具吸引力的内容,例如“website”。我检查了html,如下所示:

 <p style="display:none;">
    <label for="id_honeypot">Never send a human to do a machine's job</label>
    <input type="text" name="honeypot" id="id_honeypot" />
  </p>
class CommentForm(CommentDetailsForm):
    #use to be honeypot = forms.CharField(...
    website      = forms.CharField(required=False,
                                label=_('Never send a human to do a machines job')

def clean_honeypot(self):
    """Check that nothing's been entered into the honeypot."""
    value = self.cleaned_data["website"]
    if value:
        raise forms.ValidationError(self.fields["website"].label)
    return value
这成功地更改了django生成的html中的
名称
id
,但随后整个机制停止工作-我尝试填充这个不可见字段,提交并添加了注释

我还有一些其他的想法,但首先我真的想让它工作起来——是否可以修改默认的蜜罐
名称
id
,并让它正常工作


另外,我认为一个更简单的方法是扩展django.contrib.comments并在那里编写修改代码,而不是编写实际的django代码-实现这一点的最佳方法是什么?

如果有更多的时间来修改,我找到了两个问题的答案:

为了修改标准蜜罐或创建自己的蜜罐,您必须通过添加一个
clean\u NAME\u OF_HONEYPOT
函数以及一个
NAME\u OF_HONEYPOT
变量来扩展
CommentForm
类,这两个变量看起来都类似于标准变量,并且您还必须覆盖
security\u errors
函数,以便在字典

最好的方法是创建自定义评论应用程序,如下所述:

我希望这个答案能帮助我处境中的其他人