How To Implement The Moderation Of New Posts At Django 2.1
I'm beginner in Django. I'm write on Django 2.1, Python 3.6. Faced the following problem. I want to moderate new posts created. That is, that it was possible to put a tick in the a
Solution 1:
Well, in your PostListView, define the get_queryset method like this:
classPostListView(ListView):
...
defget_queryset(self):
queryset = super(PostListView, self).get_queryset()
return queryset.filter(moderation=True)
What happens here is that, unless the posts are moderated by admin, it will be available in PostListView. More details on filter is available in this documentation.
Post a Comment for "How To Implement The Moderation Of New Posts At Django 2.1"