-class Question(QandA):
- accepted_answer = models.OneToOneField('Answer', null=True, related_name="question_accepting")
- closed = models.BooleanField(default=False)
- closed_by = models.ForeignKey(User, null=True, blank=True, related_name='closed_questions')
- closed_at = models.DateTimeField(null=True, blank=True)
- close_reason = models.SmallIntegerField(choices=CLOSE_REASONS, null=True, blank=True)
- subscribers = models.ManyToManyField(User, related_name='subscriptions', through='QuestionSubscription')
-
- # Denormalised data
- answer_count = models.PositiveIntegerField(default=0)
- view_count = models.IntegerField(default=0)
- favourite_count = models.IntegerField(default=0)
- last_activity_at = models.DateTimeField(default=datetime.datetime.now)
- last_activity_by = models.ForeignKey(User, related_name='last_active_in_questions')
-
- favorited_by = models.ManyToManyField(User, through='FavoriteQuestion', related_name='favorite_questions')
-
- class Meta(QandA.Meta):
- db_table = u'question'
+class QuestionManager(NodeManager):
+ def search(self, keywords):
+ return False, self.filter(models.Q(title__icontains=keywords) | models.Q(body__icontains=keywords))