Search code examples
djangodjango-comments

django: How to make django comments not public by default


Using django comments framework http://docs.djangoproject.com/en/dev/ref/contrib/comments/

Not sure is there option, to make all comments non private before they passed moderation... Looks like all my comments are added to site, just after being posted. really need to change this


Solution

  • One way to do this would be to write your own comments form which inherits from the django.contrib.comments.forms.CommentForm and rewrite its get_comment_create_data function. WARNING: This code is not tested.

    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
    

    You would then hook this form into the comments systems as described in this section http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/