我有这个模型类:
class question(models.Model):
id = models.CharField(max_length=64, primary_key=True,null=False)
paper_id = models.ForeignKey(paper,null=True)
question_no = models.SmallIntegerField('question_no',max_length=6,null=True)
content = models.TextField('content',null=False)
topic_id = models.ForeignKey(topic,null=True)
subtopic_id = models.ForeignKey(subtopic,null=True)
std_answer = models.CharField(max_length=128,null=True)
marks = models.IntegerField('marks',max_length=2,null=True)
input = models.CharField(max_length=512,null=True,default=None)
type_answer = models.CharField(max_length=512,null=True)
type = models.CharField(max_length=512,null=True,default=None)
def __str__(self):
return str(self.id)
我需要列出它的所有属性,包括分别位于外部对象 Topic、Subtopic、Paper 中的 Topic.Title、Subtopic.Title 和 Paper.Title。如何在单个查询中执行此操作?