Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting Django FileFields before they're saved #18

barraponto opened this issue Sep 4, 2014 · 0 comments


Copy link

commented Sep 4, 2014

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
None yet
1 participant
You can’t perform that action at this time.