0

I think I found this a while ago but right now I don't seem to find anything when googleing.

I have a model Location:

class Location(models.Model):
    name = models.CharField(max_length=200)
    image = models.ImageField(blank=true);

and a JSON file mydata.json that will load initial data:

[
  {
    "model": "locations.location",
    "fields": {
      "name": "Cafe"
    }
  }
]

and then when I do python manage.py loaddata mydata it loads the data. So now I am wondering if it's possible to load in a picture as well generated from the json. I don't mean just a link like here I mean a format that generates an image after. I think I read somewhere that it is possible I just can't find it anymore.

Anyone an idea?

Community
  • 1
  • 1
Tom
  • 2,545
  • 5
  • 31
  • 71
  • Possible duplicate: http://stackoverflow.com/questions/5725579/images-in-django-fixtures – solarissmoke Oct 22 '15 at 03:53
  • No, I clearly say >I don't mean just a link, I mean an image that gets generated – Tom Oct 22 '15 at 04:52
  • An image that gets generated from where? Presumably you have to supply the original image in some form - the answer in that question is suggesting you copy all your images into your media directory and then import that path into Django. – solarissmoke Oct 22 '15 at 04:56
  • so when I start my app for the first time and I do `loaddata` I want this instance to be created with a picture. If I have to manually load something into the media directory, not quite the same. Maybe with a base64 code that gets encoded then – Tom Oct 22 '15 at 14:14

0 Answers0