Is there any setting that will allow me to ignore any new items. I would only want to import to update. But let's say that there is a new ID that does not currently exists in the database, I would want to ignore that.
I'm interested in the opposite settings. I'd like to import only new items and to prevent updates.
I was able to find a solution using the method skip_row
To only update existing items while ignoring any new item I use:
# Do not import any new items. Only update records
def skip_row(self, instance, original):
if original.id:
return False
return super(BookResource, self).skip_row(instance, original)
To import only new items while preventing updates you can use:
# Only import new items. Do not update any record
def skip_row(self, instance, original):
if not original.id:
return False
return True
This assumes your import_id_fields = ('id',) and your resource is called BookResource
Most helpful comment
I was able to find a solution using the method
skip_rowTo only update existing items while ignoring any new item I use:
To import only new items while preventing updates you can use:
This assumes your
import_id_fields = ('id',)and your resource is calledBookResource