2010-04-02 46 views

回答

4

做到这一点的一种方法是编写自己的评论表单,它继承了django.contrib.comments.forms.CommentForm并重写了它的get_comment_create_data函数。警告:此代码未经测试。

from django.contrib.comments.forms import CommentForm 

class MyCommentForm(CommentForm): 
    def get_comment_create_data(self): 
     data = super(MyCommentForm, self).get_comment_create_data() 
     data['is_public'] = False 
     return data 

你会再勾这种形式进入评论系统在本节 http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/

+0

我用这段代码做类似的事情;有效。一个挑剔的,字典不是一个变量的最佳名称,因为它覆盖了内建。我用数据代替。 – 2011-08-30 19:39:16

+0

是的,这是一个很好的观点。我将进行编辑。 – 2011-08-30 20:25:25