Re: Bound formset.empty_form after posting formset

2011-02-18 Thread Carl Meyer
Hi Hidde-Jan,

On Feb 18, 10:20 am, Hidde-Jan Jongsma  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.



Re: Bound formset.empty_form after posting formset

2011-02-19 Thread Hidde-Jan Jongsma
(sorry if this shows up twice)

Hi Carl,

I made a ticket and provided a patch + test. I have not yet checked
the behavior in django.contrib.admin, but since the formclass is
initialized with empty_permitted=True, the admin will *probably* not
be affected, since it would deal with empty forms but without errors.

This is the ticket: http://code.djangoproject.com/ticket/15349

Thanks,

HJ

On Feb 19, 4:03 am, Carl Meyer  wrote:
> Hi Hidde-Jan,
>
> On Feb 18, 10:20 am, Hidde-Jan Jongsma  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.



Re: Bound formset.empty_form after posting formset

2011-02-19 Thread Hidde-Jan Jongsma
Hi Carl,

I made a ticket and provided a patch + test. I have not yet checked the
behavior in django.contrib.admin, but since the formclass is initialized
with empty_permitted=True, the admin will *probably* not be affected, since
it would deal with empty forms but without errors.

This is the ticket: http://code.djangoproject.com/ticket/15349

Thanks,

HJ

On Sat, Feb 19, 2011 at 4:03 AM, Carl Meyer  wrote:

> Hi Hidde-Jan,
>
> On Feb 18, 10:20 am, Hidde-Jan Jongsma  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.
>
>

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