문제

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

도움이 되었습니까?

해결책

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/

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top