Django Shell Image Upload _io.bufferedreader No Attribute Size
My problem is that when I try to save image to my model using Django shell I get this error that I can't find solution anywere. models.py class AdImage(models.Model): ad = model
Solution 1:
The FieldFile.save
method needs to be called with an instance of django.core.files.File
, rather than a built-in python file handle. Change the save invocation to:
from django.core.files import File
imagead.full_photo.save("NowHiring.jpg", File(open("C:\\NowHiring.jpg", "rb")))
Django docs reference for FieldFile.save
.
Post a Comment for "Django Shell Image Upload _io.bufferedreader No Attribute Size"