Django: How to make django comments not public by default

Using django's comment frame http://docs.djangoproject.com/en/dev/ref/contrib/comments/

I'm not sure that there is an option to make all comments non-private before they go through moderation ... It seems that all my comments have been added to the site immediately after publication. really need to change this

+3
source share
2 answers

One way to do this is to write your own comment form, which is inherited from django.contrib.comments.forms.CommentFormand rewrite its function get_comment_create_data. WARNING: This code is not verified.

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/

+4

"auto_moderate_field" DateField DateTimeField , "medium_after" - 0.

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

moderator.register(Article, ArticleModerator)

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

+3

Source: https://habr.com/ru/post/1739601/


All Articles