Hi,
I have a model with an imageField that is working fine when using the
admin interface.
But I'm trying to make a script that load a bunch of image from a flat
file.
I can't make it works, the entry get created with a "valid" link to
the image as configured with the "upload_to" parameters,. But it
doesn't copy the image from the original location, so it aim to an
empty location.
for line in toImport:
image_info = line.split(";")
newImage = Image()
newImage.name = image_info[0]
imagefileToImportDir = os.path.join(os.path.dirname
(__file__), imagesDir)
imagefileToImport = os.path.join(imagefileToImportDir,
image_info[1])
try:
file = File(open(imagefile, 'r'))
newImage.file = file
newImage.file.save(image_info[1], file)
newImage.description = image_info[2]
newImage.save()
except IOError:
print("image not found! %s " % imagefile)
continue
Any idea where I go wrong?
Thank you
Francis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---