NOT NULL约束失败:qaforum_question.survey_id

时间:2016-09-29 06:58:14

标签: django-models

我有以下型号:

class Survey(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return str(self.name)


class Question(models.Model):
    question = models.CharField(max_length=250)
    survey = models.ForeignKey(Survey, on_delete=models.CASCADE, null=True)

    def __str__(self):
        return str(self.question) + "-" + str(self.id)

我收到以下错误:

NOT NULL constraint failed: qaforum_question.survey_id

我在网站上遇到了类似的问题,我将“null”参数设置为“True”。 请帮忙。 谢谢。

0 个答案:

没有答案
相关问题