I am testing to save ImageField in Django, but for some reason all the *.jpg files I've tried don't work while the one png I had works. Using django shell in WSL VCode terminal.
python 3.7
django 3.0
pillow 7.1.2
If I do with open():
# this has no error
f = open('loko.jpg', 'rb')#if I do
f.read() # it shows only b'', like its empty# this saves the field but the image is 0 bytes and cannot be open
object.image.save('name', File(f))
If I do with PIL:
from PIL import Image# this shows error
# PIL.UnidentifiedImageError: cannot identify image file 'loko.jpg'
img = Image.open('loko.jpg')
With the .png image I've tried, both methods work great.
What could be the problem?