开发者

Simply getting fields from django query set

class Question(models.Model):
  question_text = ...

class Answer(models.Model):
  question = models.ForeignKey ...
  user = models...

Basically, what I'm tryi开发者_JAVA技巧ng to do is return the set of questions that have been unanswered by the user. So basically, lets say answers = Answer.objects.exclude(user=my_user), i need to somehow do Question.objects.filter(id__in=answers.question.id). This last statement is obviously not going to work, but I hope you can get the idea.

Appreciate any help on this. Thanks.


Question.objects.exclude(id__in=[answer.question.id for answer in Answer.objects.filter(user='Joe')])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜