Paul Childs wrote:

I have a lot of images for the initial load and want to use a script to
get them into the database.
>
When I try to store the image in my Photo model (see the below) I get
an error.

C:\Python24\lib\site-packages\django\db\models\base.py in
_save_FIELD_file(self, field, filename, raw_contents)
   346         full_filename = self._get_FIELD_filename(field)
   347         fp = open(full_filename, 'wb')
--> 348         fp.write(raw_contents)
   349         fp.close()
   350

TypeError: argument 1 must be string or read-only buffer, not file

my guess is that the error message means exactly what it says: you're
passing in a file object instead of a buffer containing the data. try changing:

    img = open(f,'rb')
    photo1.save_image_file(f,img)

to

    img = open(f,'rb')
    photo1.save_image_file(f,img.read())

</F>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to