[Django]-IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (..))

2👍

you can not delete ScheduleFile because it’s primary key is required by
VacationEvent so you have to delete VacationEvent record before the
ScheduleFile model this can be done in several way by signal or overriding
delete function on ScheduleFile model

example:

def delete(self, using=None):
    if self.schedule_file:
        self.schedule_file.delete()
    super(ScheduleFile, self).delete(using)

Leave a comment