gpt4 book ai didi

python - 测验模型中的图像

转载 作者:行者123 更新时间:2023-12-01 05:10:21 25 4
gpt4 key购买 nike

我正在尝试自定义this django quiz app

我希望能够为每个问题和每个答案添加图像。但有些人不会有任何图像,也没有答案。最好的方法是什么?

这是实际模型:

class Question(models.Model):

quiz = models.ManyToManyField(Quiz, blank=True, )

category = models.ForeignKey(Category, blank=True, null=True, )

content = models.CharField(max_length=1000,
blank=False,
help_text="Enter the question text that you want displayed",
verbose_name='Question',
)

explanation = models.TextField(max_length=2000,
blank=True,
help_text="Explanation to be shown after the question has been answered.",
verbose_name='Explanation',
)


class Meta:
verbose_name = "Question"
verbose_name_plural = "Questions"
ordering = ['category']


def __unicode__(self):
return self.content


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

content = models.CharField(max_length=1000,
blank=False,
help_text="Enter the answer text that you want displayed",
)

correct = models.BooleanField(blank=False,
default=False,
help_text="Is this a correct answer?"
)

def __unicode__(self):
return self.content

最佳答案

使用创建新模型

  • 图像,
  • 类型 - 答案或问题
  • answer_id 或 Question_id

然后您可以在答案/问题中添加任意数量的图像。

关于python - 测验模型中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24346983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com