21👍
✅
Yes, it’s possible.
You have to put your image in your project MEDIA_ROOT.
In fixtures it will look like
[{
"pk": 1,
"model": "pictures.picture",
"fields": {
"image": "/media/gebakken_kip_met_korianderrijst_1152_x_1728.png"
}
}]
8👍
this has been asked while ago and already been answered, i am still going to put this out there:
after dumping the fixture replace all the paths with one to a suitable placeholder image, that you manually put in your media directory. you probably should choose a path your app does not use in production, like “/media/fixture/sample.jpg”. that way you could put the file into your scm of choice too.
if you have “/media” in your .gitignore (which is a good idea), don’t forget to add an exception.
as an alternative, google also turns up this: https://github.com/leetrout/django-fixturemedia
- [Django]-Django Order By Date, but have "None" at end?
- [Django]-Django REST framework: non-model serializer
- [Django]-Django – how to detect test environment (check / determine if tests are being run)
Source:stackexchange.com