def get_context_data(self, **kwargs): context = super(QuestionDetailView, self).get_context_data(**kwargs) History.generate_history(self.object, self.request) if self.object.kw: words = [self.object.title] + self.object.kw _re = r'(%s)' % ('|'.join(words)) related_question = Question.objects.filter(Q(body__regex=_re) | Q(title__regex=_re)).exclude( id=self.object.id)[:20] context['related_question'] = related_question context['invites'] = Invite.objects.filter(content_type=ContentType.objects.get_for_model(self.object), object_id=self.object.id) return context
def get_context_data(self, **kwargs): context = super(QuestionDetailView, self).get_context_data(**kwargs) History.generate_history(self.object, self.request) if self.object.kw: words = [self.object.title] + self.object.kw _re = r'(%s)' % ('|'.join(words)) related_question = Question.objects.filter( Q(body__regex=_re) | Q(title__regex=_re)).exclude(id=self.object.id)[:20] context['related_question'] = related_question context['invites'] = Invite.objects.filter( content_type=ContentType.objects.get_for_model(self.object), object_id=self.object.id) return context
def get(self, request, *args, **kwargs): response = super(ArticleDetailView, self).get(request, *args, **kwargs) History.generate_history(self.object, request) return response
def get(self, request, *args, **kwargs): response = super(UserDetailView, self).get(request, *args, **kwargs) if self.object != request.user: History.generate_history(self.object, request) return response