This is just a quick question to better understand how django-import-export
works. Say I have a few objects of some model already saved in my database. If I try to import from a file containing the data for an object that is already in the database (so, an object with the pk
in the import file already exists in the database), the change list shows that this object is being updated.
My question is this: does the update process involve deleting the old instance of that object (the one that is saved in the database) and then adding the one that we are importing as if it was a new instance? or is it actually updated using, for example, the instance.update(attr=new_val)
method?
CodePudding user response:
it is updated (not deleted) by loading the instance from the db, updating the fields on the instance from your import, and then calling instance.save()