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')])
精彩评论