[Django]-How to get django to upload an image file via fixtures

2👍

No idea why I didn’t come earlier to this conclusion but it works if you just place the file with name specified in the fixtures file in the directory you want to have it. For example:

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

and then put VW.jpg where your media directory is located, for example:

media/VW.jpg

It doesn’t get uploaded this way but it’s in the database and accessible over the admins panel

👤Tom

Leave a comment