IntegrityError Insert or update on table “orders_order” violates foreign key constraint "

前端 未结 1 379
遥遥无期
遥遥无期 2021-01-12 00:17

I am trying to build an ecommerce site in Django 1.7 everything works except when I try to use the checkout, I got the following error. I am not sure wht it is doing this a

相关标签:
1条回答
  • 2021-01-12 00:58

    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.

    0 讨论(0)
提交回复
热议问题