Posting Django FileFields before they're saved #18

barraponto opened this Issue Sep 4, 2014 · 0 comments


None yet

1 participant


I'm having issues when trying to POST Django FileFields files before they're saved. I'm trying to post them during a model save override (to get extra data). So in override it looks like this:

class MyModel(models.Model):
    image = models.ImageField()
    def save(self, *args, **kwargs):
        res =, headers=headers, params={
            "image_request[image]": self.image.file
        # @todo: add some field from res.body to my model.
        super(MyModel, self).save(*args, **kwargs)

Problem is, before the model is saved, self.image.file is either an instance of InMemoryUploadedFile or TemporaryUploadedFile. When I have the latter (or after model is saved), I have to pass in open(self.image.file.path), as won't work. I wonder why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment