假设我有跟随Question
和Answer
class Question(models.Model):
category = models.ForeignKey(Category)
#contains all the choices of questions
class Options(models.Model):
question = models.Foreignkey(Question)
#contains question, choice choosen by user, category
class Answer(models.Model):
question = models.Foreignkey(Question)
option = models.ForeignKey(Option)
category = models.ForeignKey(Category)
我的查询集如下
questions = Question.objects.filter(category_id=1)
answers = Answer.objects.filter(category_id=1)
questions
查询集包含所有类别问题,answers
查询集包含每user
个问题的所有答案。现在我想显示所有问题的答案和警告信息到未答复的问题,实现这一目标的最佳方法是什么?