We have about 700 product variations. We have all the images named based on
the SKU and variation options of the products.
I am trying to write a script to import images. However, I cannot create a
ProductImage object for products:
from satchmo_utils.thumbnail.field import ImageWithThumbnailField
from product.models import Product, ProductImage
>>> from satchmo_utils.thumbnail.field import ImageWithThumbnailField
>>> from product.models import Product, ProductImage
>>> p =
KeyboardInterrupt
>>> p = Product.objects.get(sku='2833')
>>> f = open("/tmp/image_export/2833.jpg")
>>> i = ImageWithThumbnailField(f)
>>> pi = ProductImage(p.id, i)
>>> pi.save()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File
"/var/www/virtualenv/satchmo_stage/lib/python2.6/site-packages/django/db/models/base.py",
line 460, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File
"/var/www/virtualenv/satchmo_stage/lib/python2.6/site-packages/django/db/models/base.py",
line 546, in save_base
for f in meta.local_fields]
File
"/var/www/virtualenv/satchmo_stage/lib/python2.6/site-packages/django/db/models/fields/subclassing.py",
line 28, in inner
return func(*args, **kwargs)
File
"/var/www/virtualenv/satchmo_stage/lib/python2.6/site-packages/django/db/models/fields/related.py",
line 872, in get_db_prep_save
if value == '' or value == None:
File
"/var/www/virtualenv/satchmo_stage/lib/python2.6/site-packages/django/db/models/fields/__init__.py",
line 124, in __cmp__
return cmp(self.creation_counter, other.creation_counter)
AttributeError: 'str' object has no attribute 'creation_counter'
Also, if anyone have any ideas how I could have a variation display images
the following way:
- If variation has an image, display it
- Otherwise, display image of the configurable image
Thanks for any help you may offer!
--
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/satchmo-users/-/F9W4bIy39bcJ.
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/satchmo-users?hl=en.