Help with My Inventory Import Script

36 görüntüleme
İlk okunmamış mesaja atla

Tim Walzer

okunmadı,
1 Tem 2013 14:28:461.07.2013
alıcı satchmo-d...@googlegroups.com
I have put together an import script to load inventory from a CSV.  I thought everything was working fine until I took a look at the images that were imported.

For reference the image section of my script looks like this:
 
file = <full path to image> # /home/ubuntu/web/<uri>/store/static/images/<file_name>.jpg 
image = ProductImage(product=product)
image.picture = file
image.save() 

After importing the products, I noticed that in the admin, the path to to the image was: "/media/home/ubuntu/web/<uri>/store/static/images/productimage-picture-<file name>.jpg"

In the filesystem I realized that the images were now at "/home/ubuntu/web/<uri>/store/static/home/ubuntu/web/<uri>/store/static/images/productimage-picture-<file name>.jpg"

After digging into this I realized that with 'RENAME_IMAGES' set to true, the images were not only being renamed, but because of an issue with relative vs absolute paths, they were being moved as well.

So, not wanting my images moved I set 'RENAME_IMAGES' to false and ran the script again.

Now in the admin the path to the images is: "/home/ubuntu/web/<uri>/store/static/images/productimage-picture-<file name>.jpg"  Note that the /media has been dropped from the beginning.
However in this case the image does not show in the admin section because the server doesn't know how to serve that path.  Fortunately Sorl Thumbnail correctly creates and caches the thumbnail so in the store the image is displayed correctly.

So, my question is, what is the likely cause of this issue and how do I get the path in the admin section to be "/media/images/<file name>.jpg"?

Williams Mendez Taveras

okunmadı,
2 Şub 2014 06:29:102.02.2014
alıcı satchmo-d...@googlegroups.com

This is what works for me:

ProductImage.objects.get_or_create(product=product, picture=('images/%s' % image), caption=product_name)
Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti