How to get django to upload an image file via fixtures

Viewed 1106

I have a class in my models.py:

class Car(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4)
    create_date = models.DateTimeField('date added', auto_now_add=True)
    modify_date = models.DateTimeField('date modified', default=timezone.now)
    name = models.CharField(max_length=200)
    image_file = models.ImageField(
        upload_to=upload_to_company, null=True, blank=True)

and a JSON for fixtures like this:

   [
      {
        "model": "polls.car",
        "fields": {
            "id":"09734145-7a15-4c84-8b7c-eaab4112cbaa",
            "name": "VW",
            "create_date": "2015-01-01T00:00:00+00:00"
        }
      }
    ]

which I load as a fixture. Now I want it to get it to load an image as well, however when I insert "image_file":"VW.jpg" (VW.jpg is in the same folder as the JSON). VW.jpg shows up in the admin's panle but it doesn't upload the actual picture.

Anyone an idea or a hint for where to look?

1 Answers
Related