def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['comments'] = filter_valid_comment_by_article( self.kwargs['article_id']) context['comment_form'] = CommentForm() context['form_error'] = self.request.GET.get('form_error', '') return context
def comments(self): from app.db_manager.content_manager import filter_valid_comment_by_article return filter_valid_comment_by_article(self.id)
def comment_post_delete(sender, **kwargs): a_meta = get_article_meta_by_article(kwargs['instance'].article_id) a_meta.comment_num = filter_valid_comment_by_article( kwargs['instance'].article_id).filter(type=201).count() a_meta.save()
def comments(self): if self._comments is None: from app.db_manager.content_manager import filter_valid_comment_by_article self._comments = filter_valid_comment_by_article(self.id) return self._comments