[Fixed]-Error after creating a foreign key: django.db.utils.IntegrityError: MyApp_job__new.level_id may not be NULL

1👍

Since you haven’t applied migrations 0013 to 0019, the easiest thing to do might be to delete these files, then rerun makemigrations (check in a copy of the files if you’re using version control or take a backup first).

If you need more fine grained control, you could edit the 0013 migration which is failing, and set null=True to prevent the IntegrityError.

    migrations.AddField(
        model_name='job',
        name='level',
        field=models.ForeignKey(default=None, blank=True, null=True, to='SolutionsForLanguagesApp.Level'),
        preserve_default=False,

Leave a comment