Python 测验模型中的图像
我正在试着定制 我希望它可以为每个问题和每个答案添加图像。但有些人也不会有任何图像。最好的方法是什么 这是实际模型:Python 测验模型中的图像,python,django,django-models,django-admin,Python,Django,Django Models,Django Admin,我正在试着定制 我希望它可以为每个问题和每个答案添加图像。但有些人也不会有任何图像。最好的方法是什么 这是实际模型: class Question(models.Model): quiz = models.ManyToManyField(Quiz, blank=True, ) category = models.ForeignKey(Category, blank=True, null=True, ) content = models.CharField(max_l
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
使用创建新模型
- 形象,
- 键入-答案或问题
- 答案或问题
然后,您可以在回答/问题中添加任意数量的图像。这是一种非常流行的解决方案。