[Django]-Django.db.utils.IntegrityError: The row in table 'main_page_projects' with primary key '1' has an invalid foreign key

3👍

You can not create an entry in a database table (or modify one by adding a field via migrations) with a ForeignKey that points to a non existing entry on the target table ("Profile" in your case). It does not make sense – so you get the integrity error.
Leave away the default=1 and make it "blank=True, null=True" so you can leave it empty upon creation or during migration.

Leave a comment