0

The django import-export documentation says

report_skipped= True

Controls if the result reports skipped rows Default value is True


skip_unchanged= False

Controls if the import should skip unchanged records. Default value is False


I Don't quite understand what they are trying to say, I have used them(copy-pasted without understanding).Can someone please explain what they are used for. Thank you.
Saravanan
  • 566
  • 5
  • 13

1 Answers1

2

It's a good idea to look directly into the source if you are unsure. Obviously I don't need to spell out why 'copy pasted without understanding' is a bad idea.

Both of these flags control the behaviour that occurs when an import detects that there are existing stored records matching those that are to be imported.

The import logic needs to have this check to avoid the risk of unnecessary duplicates appearing after the import. If you can include an identifier in the import which is a global id for the import row, then this helps a lot in making sure that imports are safe, and means you can re-run if necessary without causing duplicates.

Existing records will be detected using the import_id_fields setting.

skip_unchanged

This flag controls whether any existing rows will be skipped if the persisted row is an exact match for the imported row. A skipped row means that a persisted record is not updated.

If enabled, the default logic (skip_row()) will check each field declared in fields and will skip the row if all values match imported values.

The default value is False, meaning that if an existing row is found during import, then it will be updated with the values in the import.

report_skipped

This setting means that if a row is skipped then it will be appended to a list which can be read once the import is completed. The main use case for this is for logging or reporting the outcome of the import. For example, X rows were created, Y rows were updated, Z rows were skipped.

This is True by default. If you really don't need a report of skipped rows, then setting this value to False will save some memory and processing time.

Matthew Hegarty
  • 3,791
  • 2
  • 27
  • 42