﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8912	File storage and save/commit=False	shadfc		"Background:  I noticed this when playing with save_formset() on ModelAdmin in order to modify the data for a FileField on an inline model before it gets sent to S3 via a custom filestorage backend.

In admin.py
{{{
    def save_formset(self, request, form, formset, change):
        instances = formset.save(commit=False)
        for instance in instances:
            if not instance.id:
                raise Exception('testing file creation')
            instance.save()
        formset.save_m2m()
}}}

Now, when saving a new inline instance which has a file field, the exception is raised before that instance gets save()'d.  I kept noticing, however, that I would still get the full uploaded file with the proper name in my S3 account.  So, I raised an exception in the _save() on my custom backend and walked it back to the formset.save(commit=False) call.  

It seems to me that the commit=False should keep file writes from happening; it doesn't.  Looking in django/db/models/fields/files.py, the save() takes a save argument but doesn't use it when dealing with the save call to the storage backend. If the argument was passed along to the save on the storage backend, then it could decide whether or not to actually write the file."	New feature	new	File uploads/storage	1.0	Normal			jay.wineinger@…	Accepted	0	1	0	1	0	0
