straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

formset.save(initialize={}) is not supported #200

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm wondering if this can be supported somehow. For a FormWithSets form
that requires a pre-filled in field (like current user), the only
conceivable way (for me) is to create something like:

def MyForm(user, *args, **kwargs):
    class _MyForm(forms.ModelForm):
        some_field = FormSetField(Model)
        def save(self, *args, **kwargs):
            return super(_MyForm, self).save(initialize={'user': user},
*args, **kwargs)

    _MyFormSet = FormWithSets(_MyForm)
    return _MyFormSet(*args, **kwargs)

That looks ugly.

I guess it is hard to identify which of the initialize entries are for
which form. Would it be a good idea to support a multi-level initialize
dictionary?

Original issue reported on code.google.com by google%o...@gtempaccount.com on 6 Aug 2009 at 6:23