correct import images, better target dir management
authorymh <ymh.work@gmail.com>
Fri, 22 Jun 2018 11:34:42 +0200
changeset 11 93228a694ce7
parent 10 27bc4cb6cb4e
child 12 8895d41be7e2
correct import images, better target dir management
src/iconolab_mcc/management/commands/importimages.py
--- a/src/iconolab_mcc/management/commands/importimages.py	Tue Jun 19 17:59:18 2018 +0200
+++ b/src/iconolab_mcc/management/commands/importimages.py	Fri Jun 22 11:34:42 2018 +0200
@@ -310,8 +310,8 @@
                     )
             print(
                 '## Converting image and moving it to static dir, creating Image and Item objects')
-            self.target_dir = os.path.join(settings.MEDIA_ROOT, 'uploads')
-            print('### Images will be stored in '+self.target_dir)
+            target_dir = os.path.join(settings.MEDIA_ROOT, Image.media.field.upload_to)
+            print('### Images will be stored in ' + target_dir)
             for item in filtered_csv_data:
                 print('#### Computing metadatas for item ' +
                       item['REF']+' (natural key)')
@@ -388,7 +388,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, self.target_dir)
+                        item_joconde_ref, collection, new_metadata, item['SRC_IMG_FILES'], options, self.source_dir)
 
             print('# All done!')