diff -r 56608f42821f -r bff393b23a68 src/iconolab_mcc/management/commands/importimages.py --- a/src/iconolab_mcc/management/commands/importimages.py Fri Jun 22 17:34:37 2018 +0200 +++ b/src/iconolab_mcc/management/commands/importimages.py Sat Jun 23 02:04:20 2018 +0200 @@ -343,7 +343,8 @@ item_photo_credits = item['PHOT'] item_inventory_number = item['INV'] item_joconde_ref = item['REF'] - if ItemMetadata.objects.filter(item__collection=collection, natural_key=item_joconde_ref).exists(): + natural_key="%s|%s" % (collection.name,item_joconde_ref) + if ItemMetadata.objects.filter(item__collection=collection, natural_key=natural_key).exists(): print('#### An item with ' + item['REF']+' for natural key, already exists in database in the import collection') @@ -366,7 +367,7 @@ folder = Folder.objects.get(original_id=folder_id) item_metadata = ItemMetadata.objects.get( - item__collection=collection, natural_key=item_joconde_ref) + item__collection=collection, natural_key=natural_key) item = item_metadata.item item.folders.add(folder) @@ -388,7 +389,7 @@ "joconde_ref" : item_joconde_ref } self.create_item_and_metadata( - item_joconde_ref, collection, new_metadata, item['SRC_IMG_FILES'], options, self.source_dir) + natural_key, collection, new_metadata, item['SRC_IMG_FILES'], options, self.source_dir) print('# All done!')