First, I created a new object and I just wanted to switch the pk to another value and update the database, and that didn't work, so I had to do something like this:
c._id = c_id
for k in c.fields:
c.modified_fields.add(k)
c.update()
Second, notice the c.update(), that was because c.save() didn't work, figure out why it didn't work. c_id was definitely a valid primary key.
One thing that could be done is if setting the _id then that will trigger all the fields to be marked as modified. Also, we could add a force() method that would save all the fields regardless of whether they were dirty or not.
First, I created a new object and I just wanted to switch the pk to another value and update the database, and that didn't work, so I had to do something like this:
Second, notice the
c.update()
, that was becausec.save()
didn't work, figure out why it didn't work.c_id
was definitely a valid primary key.One thing that could be done is if setting the
_id
then that will trigger all the fields to be marked as modified. Also, we could add a force() method that would save all the fields regardless of whether they were dirty or not.