On Wed, Sep 10, 2008 at 7:38 AM, Brian Rosner <[EMAIL PROTECTED]> wrote: > > On Wed, Sep 10, 2008 at 8:13 AM, shadfc <[EMAIL PROTECTED]> wrote: >> The problem is that FieldFiles get saved to the storage backend even >> on a save(commit=False), and (according to a more knowledgeable SeanL- >> on #django), the FieldFile will only get saved once, the first time >> through. So the only way I can accomplish what I want is to do two >> saves to my backend -- one when the formset is saved with commit=False >> and then I must call the storage backend's save() directly in order to >> upload the changes I've made to the mp3 file in memory. > > Ouch. In a formset sounds like you could be calling save up to N*2 times. > >> I think that the commit=False (or save=False in FieldFile.save() ) >> should not do the save to the storage backend. > > Agreed. I have been considering treating FileFields the same as > many-to-many fields when commit=False in a ModelForm. In the event > that commit=False a new method is available to perform the file saving > explicitly. This would help in the event of wanting to name the file > the same as the primary key for instance.
That sounds like a promising idea to me, but I'd want to see the details. I was writing some code the other day that was trying to poke the username into part of the upload_to path. I made it work with a custom ModelForm __init__ method, but commit=False seems like it would have been a lot cleaner, or at least that was my first instinct about what to try. To address Karen's backwards-incompatibility concern, perhaps a new 'commit_files' argument would be in order. Joseph --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---