4

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

Oleg Tarasenko
  • 9,324
  • 18
  • 73
  • 102

2 Answers2

5

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/

Mark Lavin
  • 24,664
  • 5
  • 76
  • 70
  • I used this code to do something similar; it worked. One nitpick, dict is not an optimal name for a variable as it overrides the builtin. I used data instead. – Gringo Suave Aug 30 '11 at 19:39
4

Setup a comment moderator and set 'auto_moderate_field' to a DateField or DateTimeField on the model and 'moderate_after' to 0.

class ArticleModerator(CommentModerator):
    email_notification = True
    enable_field = 'enable_comments'
    auto_moderate_field = 'pub_date'
    moderate_after = 0

moderator.register(Article, ArticleModerator)

More information in the docs: https://docs.djangoproject.com/en/dev/ref/contrib/comments/moderation/#built-in-moderation-options

netboy
  • 41
  • 1