Update primary key Django MySQL

后端 未结 3 1868
南方客
南方客 2021-01-18 10:34

sorry for my poor english, my problem is:

I try to update the PK in Django with the method .save() but when i save the object Django duplicate the object withe the s

3条回答
  •  我在风中等你
    2021-01-18 11:05

    First you should make sure that the object with the primary key "11111111L" has been added to your table. Probably doing something along the lines of:

    e3 = Empleados.objects.get(pk="11111111L")

    And then making sure that e3 contains . Once you confirm that it is there, then you can just use the following statement to get rid of the object with the primary key "56789034U" (assuming you keep e2 around):

    e2.delete()

提交回复
热议问题