Tuesday, April 24, 2012

Re: Ignoring empty forms in a formset

I am doing that:

<input id="id_form-TOTAL_FORMS" type="hidden" value="2" name="form-TOTAL_FORMS">
<input id="id_form-INITIAL_FORMS" type="hidden" value="0" name="form-INITIAL_FORMS">
<input id="id_form-MAX_NUM_FORMS" type="hidden" name="form-MAX_NUM_FORMS">

When I add a form to formset, I increase form-TOTAL_FORMS. But this doesn't affect processing of empty forms.

Martin

On Monday, April 23, 2012 4:48:29 PM UTC+2, Marcin wrote:
You will want to edit the management form values on the client side, as described in the documentation.

On Mon, Apr 23, 2012 at 15:42, Martin Tiršel <martin.tirsel@gmail.com> wrote:
Nobody knows how to ignore empty forms in a formset? I have to write some custom method on a form that checks all fields and returns False if any of the fields is filled or is there any other solution?

Martin

On Sunday, April 22, 2012 6:44:53 PM UTC+2, Martin Tiršel wrote:
Hello,

I have a formset and some JavaScript to add more forms into this formset. In a view, I iterate through the formset saving (not a ModelForm just Form with save method) each form:

for form in formset:
    form.save()

But I want to ignore empty forms that were added by JavasScript and not removed. How can I do this?

Thanks,
Martin
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Y_DfzKjYiYwJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Marcin Tustin
Tel: 07773 787 105

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/r4uzO58TzEsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment