>From 
>https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.fields.files.FieldFile.save,
> the content should be an instance of django.core.files.File.  So you code 
>should look like:

from dango.core.files import File
f = open(“c:\\NowHiring.jpg”, “rb”)
myfile = File(f)
imaged.full_photo.save(“NowHiring.jpg”, myfile)


> On Mar 2, 2016, at 1:31 AM, Povilas Kudriavcevas <netcri...@gmail.com> wrote:
> 
> 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 = models.ForeignKey(Ad)
>    full_photo = models.ImageField(upload_to='uploads/', blank=True)
> 
> I import models create AdImage instance add 'ad' and try to
> 
> imagead.full_photo.save("NowHiring.jpg",open("C:\\NowHiring.jpg", "rb"))
> 
> but i get an error
> 
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File 
> "C:\Users\hp\Envs\platform\lib\site-packages\django\db\models\fields\file
> s.py", line 106, in save
>     self._size = content.size
> AttributeError: '_io.BufferedReader' object has no attribute 'size'
> 
> Using: Python 3.5, Django 1.9
> 
> What could I do ?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com 
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users 
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/d89d4906-0494-4d01-bd6a-428f29466f4d%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/d89d4906-0494-4d01-bd6a-428f29466f4d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

Peter of the Norse
rahmc...@radio1190.org



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/737C0E9D-88C9-4B19-8B89-63399F98A531%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to