IntegrityError duplicate key value violates unique constraint - django/postgres

后端 未结 11 1027
清歌不尽
清歌不尽 2020-11-28 18:44

I\'m following up in regards to a question that I asked earlier in which I sought to seek a conversion from a goofy/poorly written mysql query to postgresql. I believe I suc

11条回答
  •  时光取名叫无心
    2020-11-28 19:23

    I encountered this error because I was passing extra arguments to the save method in the wrong way.

    For anybody who encounters this, try forcing UPDATE with:

    instance_name.save(..., force_update=True)
    

    If you get an error that you cannot pass force_insert and force_update at the same time, you're probably passing some custom arguments the wrong way, like I did.

提交回复
热议问题