Jacob Kaplan-Moss wrote:
> On Tue, Feb 17, 2009 at 1:15 PM, Tonu Mikk <tm...@umn.edu> wrote:
>   
>> Looking at the database, I see a photo and thumbnail columns, but there
>> is no data.  Do I need to write code to store a link to images in the
>> photo and thumbnail columns?
>>     
>
> Yes, that's it. Read the section of the file reference titled
> "Additional methods on files attached to objects"
> (http://docs.djangoproject.com/en/dev/ref/files/file/#additional-methods-on-files-attached-to-objects).
>
> You'll want code that looks something like
> `my_bookmark.photo.save('file_name'.jpg, file_contents)`.
>   
Jacob, thank you.  If I understand this correctly, I can save the files 
that are attached to objects using the above method instead of this from 
page
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#topics-http-file-uploads
 
:

def handle_uploaded_file(f):
    destination = open('some/file/name.txt', 'wb+')
    for chunk in f.chunks():
        destination.write(chunk)
    destination.close()


Tonu 



--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to