Hi all,
Due to a model change, I would like to move an image field's data to
another model.
My model is something like this:
class Product(models.Model):
...
image = models.ImageField(upload_to='image')
...
I would like to move it with the existing data, to a different class
so that products and images will have a 1-n relation.
class Image(models.Model):
product = models.ForeigKey(Product, related_name='image_set')
image = models.ImageField(upload_to='image')
In the django shell, I tried the following but get an 'SQL logic
error':
>>> from products.models import *
>>> for product in Product.objects.all():
>>> Image.objects.create(product=product, image=product.image)
Is there a way to do such an import in django way, or should I go the
raw SQL path?
thanks,
omat
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---