On Fri, Jun 17, 2011 at 4:15 PM, Bas Peschier <bas.pesch...@gmail.com> wrote:
> Hello everyone,
>
> after discussion on IRC with rasca I opened up a ticket [1] about
> making FormSets declarable.
>
> We have been down this route with ModelForm and it seems to make sense
> to be able to declare your FormSet somewhere instead of having to
> generate it.
>
> The idea given is you can do:
>
>  class MyFormSet(formsets.FormSet):
>    can_delete = True
>    form = MyForm
>    extra = 3
>
> This is almost possible already (BaseFormSet actually can be
> subclassed if you add all the arguments to your definition), but it
> might be interesting to think about the consequences. rasca is working
> on extending CBV [2] which can use this.
>
> In the mean time we looked at "removing" the factories, but for now
> the admin makes good use of completely flexible generation of
> ModelForm and ModelFormSets.
>
> Ideas?
>
> /Bas
>
>
> [1]: https://code.djangoproject.com/ticket/16289
> [2]: https://code.djangoproject.com/ticket/16256

Okey, so this have been raised before in #10403 [0]. It's marked DDN
by jacob, but now we have some concrete usages where we might benefit
from the declarable FormSets and friends.

Actually, for the new CBV what would came in handy is having the
defaults set as attributes of the class; and in the factories, only
override those attributes whose value isn't None with type(). This
way, for example in the inlines generic cbv, the user can set some
attrs such as can_delete, fields and exclude for each InlineFormSet
and the view can handle the parent_class, without overriding with None
the user set attrs.

It's completely backwards compatible and the code for these cbv would
end up beeing much cleaner.

Regards,
    Iván

[0] https://code.djangoproject.com/ticket/10403

-- 
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 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to