DDN on #9284

2 views
Skip to first unread message

Joseph Kocherhans

unread,
Mar 23, 2009, 4:32:05 PM3/23/09
to django-d...@googlegroups.com
#9284 [1] Has a patch to make BaseModelFormSet call ModelForm.save() when saving objects rather than using completely custom code as it does now. I think this is the "right thing (tm)" to do, but it will break people's code who have overridden the formset's __init__ method and mucked around with the "initial" argument. I don't really feel bad about said breakage, because hey, you're messing with internals, you should know what you're doing.

Joseph


Malcolm Tredinnick

unread,
Mar 23, 2009, 8:17:14 PM3/23/09
to django-d...@googlegroups.com
Hey Joseph,

On Mon, 2009-03-23 at 15:32 -0500, Joseph Kocherhans wrote:
> #9284 [1] Has a patch to make BaseModelFormSet call ModelForm.save()
> when saving objects rather than using completely custom code as it
> does now. I think this is the "right thing (tm)" to do, but it will
> break people's code who have overridden the formset's __init__ method
> and mucked around with the "initial" argument. I don't really feel bad
> about said breakage, because hey, you're messing with internals, you
> should know what you're doing.

I've looked at this briefly. I haven't got a strong opinion about the
effects of the backwards incompatibility yet (although I've been
thinking about it in odd moments since I saw you post that patch),
although your logic isn't totally from Outer Space.

The approach looks better. I'd be tempted to lift a couple of those
leading-underscore methods up to just being normal methods. Found myself
having to override a few of those things lately when wanting to use the
formset infrastructure in other ways. It won't kill us to allow inital-,
total- and management-forms getters to be overridden, I don't think.

Regards,
Malcolm


Alex Gaynor

unread,
Mar 24, 2009, 11:58:00 PM3/24/09
to django-d...@googlegroups.com
I agree with the idea that ModelFormsets should call the methods on the base ModelForm.  In my view the purpose of a formset is to aggregate methods on a form, and as such I basically expect it to call the underlying methods where relevant, as_table is a good example of this.  As for the backwards compatibility concerns, as you say these are internals, no lifeime warranties here :)

Alex

--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

Joseph Kocherhans

unread,
Mar 29, 2009, 6:29:31 PM3/29/09
to django-d...@googlegroups.com
On Mon, Mar 23, 2009 at 7:17 PM, Malcolm Tredinnick <mal...@pointy-stick.com> wrote:

The approach looks better. I'd be tempted to lift a couple of those
leading-underscore methods up to just being normal methods. Found myself
having to override a few of those things lately when wanting to use the
formset infrastructure in other ways. It won't kill us to allow inital-,
total- and management-forms getters to be overridden, I don't think.

I'll probably make those methods public and check this in sometime during the next few days at the PyCon sprint, maybe with some docs to the effect of "you don't need to override these unless you're Malcolm". If anyone wants to convince me to table this for 1.2, please speak up.

Joseph
Reply all
Reply to author
Forward
0 new messages