Hello all, I have spent considerable time going through the documentation but have been unable to find clear information about how to save an image after uploading it via a form. I think I have somehow missed it. After trial and error, I have done it in this way:
content = request.FILES['image'] foo.img.save(filepath, content=content,save=False) here foo is an instance of the Foo model, which has an ImageField named img Is this the recommended way to upload an image (for forms that are not modelform)? And I update an imagefield (ie, set it to point another file) by setting it to its relative path against the path defined in the MEDIA_ROOT constant. I wonder if this is also correct. A third question is that when I use the default option for the ImageField, the field is set to an absolute path (MEDIA_ROOT + mypath), and this stems problems such as foo.img.url() giving a path instead of a url. How can I prevent that? Thanks for your help in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---