Hi Hidde-Jan,

On Feb 18, 10:20 am, Hidde-Jan Jongsma <m...@hidde-jan.nl> wrote:
> Lately, I've been working a lot with Django's modelformsets in
> combination with javascript. The BaseFormSet implements a handy method
> _get_empty_form, accessible through the empty_form property. This
> method checks whether formset.is_bound is True, and if it is, updates
> the kwargs passed to the formclass with the supplied data and files.
>
> This behaviour strikes me as odd. It results in a form that can no
> longer be considered empty, but is bound and, possibly, can contain
> errors. Of course, this only happens *after* the formset has been
> posted. As a result, a formset.empty_form can no longer be used as a
> (javascript) template for creating new forms on the client side, since
> it is unpredictable.
>
> Is there a specific reason that it was implemented in this way? In my
> opinion, an unbound empty_form would make much more sense.

I agree with you. I can't see any reason why the empty_form for a
bound formset should be any different than for an unbound one. The
intended use for empty_form is as a template for Javascript add-
another behavior, and such a template should always be a predictably
empty form with no errors.

If you can file a bug on this, that'd be great. If you can provide a
patch with tests, double-great. If you can also confirm that it has no
negative impact on the admin's use of formsets (or that this problem
is present in the admin currently and this fixes it), triple-great ;-)

Carl

-- 
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