6
You have to pass an image not in data
, but in the files
parameter of the form.
from django.core.files.uploadedfile import SimpleUploadedFile
img = open('photocompetitions/static/img/body_bg.jpg')
uploaded = SimpleUploadedFile(img.name, img.read())
photoform = PhotoForm(data_photo, files={'image': uploaded})
2
You need to use ‘rb’ options for open file:
'image': open('photocompetitions/static/img/body_bg.jpg', 'rb')
- [Django]-Django/Python convert PDF using shell (os.system/Popen) not working in production
- [Django]-How to only sync custom permissions with syncdb?
0
Did you try to use a bmp rather than a jpg?
I remember that there is an issue with the way PIL is loaded by the django test framework.
the jpg format may not be enabled correctly in this case but bmp should be ok.
I hope it helps
Source:stackexchange.com