def get_context_data(self, **kwargs): context = super(PostListView, self).get_context_data(**kwargs) context['users'] = False context['notifications'], context['unread_count'] = recieve( self.request.user) check = User.objects.filter(username=self.request.user, is_chief=True) if check: context['users'] = True return context
def get_context_data(self, **kwargs): context = super(PostDetailView, self).get_context_data(**kwargs) comments = Comment.objects.filter( blog_id=self.get_object().id).order_by('-comment_datetime')[:5] context['notifications'], context['unread_count'] = recieve( self.request.user) # provide the columns name in values_list context['comments'] = comments.values_list('user_id__username', 'comment', 'id') context['reply'] = Reply.objects.filter(blog_id=self.object.pk) context['form'] = CommentForm(initial={'post': self.object}) return context
def get_context_data(self, **kwargs): # print(self.pk) context = super(CommentReplyView, self).get_context_data(**kwargs) reply = Reply.objects.filter(which_comment_id=self.get_object().id ).order_by('-reply_datetime')[:5] comment = Comment.objects.filter(id=self.get_object().id) context['post'] = comment.values_list( 'blog_id__title', 'blog_id__id', ) context['notifications'], context['unread_count'] = recieve( self.request.user) # provide the columns name in values_list context['reply'] = reply.values_list('user_id__username', 'reply') context['form'] = ReplyForm(initial={'post': self.object}) return context
def get_context_data(self, **kwargs): context = super(HomeView, self).get_context_data(**kwargs) context['notifications'], context['unread_count'] = recieve( self.request.user) return context