django-nested-admin icon indicating copy to clipboard operation
django-nested-admin copied to clipboard

Integrity Error

Open jas-odoo opened this issue 5 years ago • 0 comments

class Survey(TimeStampedModel): title = models.CharField(_('Title'), max_length=100)

class SurveyQuestion(TimeStampedModel): question = models.CharField(('Question'), max_length=100) survey = models.ForeignKey(Survey, on_delete=models.CASCADE, null=True, blank=True) is_required = models.BooleanField(('Required'), default=False) question_type = models.CharField(('Question Type'), max_length=8, choices=TYPE_CHOICES, default='mcq')

class SurveyQuestionAnswer(TimeStampedModel): answer = models.CharField(_('Option'), max_length=100) survey_question = models.ForeignKey( SurveyQuestion, on_delete=models.CASCADE, null=True, blank=True)

Integrity Error comes when trying to delete Question.

(1452, 'Cannot add or update a child row: a foreign key constraint fails (edxapp.risesurvey_surveyquestionanswer, CONSTRAINT risesurvey_surveyque_survey_question_id_53f161a8_fk_risesurve FOREIGN KEY (survey_question_id) REFERENCES risesurvey_surveyquestion)')

jas-odoo avatar Jul 15 '19 05:07 jas-odoo