Django point ImageField to an already existing image

Viewed 1449

I have a model which has an Image field:

class Foo(models.Model):
    image = models.ImageField(upload_to = "bar", blank = True)

I am downloading an image over the internet using urllib like this:

urllib.urlretrieve(img_url, img_path)

Now I want to point the Image field to this downloaded image saved as img_path. I have tried using Image.open() from PIL to first open the file and point to it and obj.image.save(File(open(file_path))) using django.core.files.File but they don't seem to work. Is there an alternate way to implement this?

3 Answers
Related