[Solved]-IntegrityError Insert or update on table "orders_order" violates foreign key constraint "


The important detail is in this line:

DETAIL:  Key (billing_address_id)=(1) is not present in table "accounts_useraddress".

The problem is that you are trying to link an order with a billing address which is not yet present in the database.

In your code you’ll need to make sure that the billing address is saved to the database before you try and save an object that is related to it by foreign key.


Leave a comment