Saturday, May 26, 2012

Re: model form_set can not delete

That's by design. The individual Modelforms don't delete. What you can do is look to see if they are marked, and deleted them manually.

if formline.DELETE:
formline.instance.delete()

On May 23, 2012, at 6:01 PM, Min Hong Tan wrote:

> Hi there,
>
> i have a problem whereby, if i for form in formset line by line and run form.save(). my delete (ticked) item will not be deleted.
> and if i 'm direct using formset.save(). it did deleted. where am i code wrong already?
>
>
> q1 = modelformset_factory(CustomerDetail,
> form= CustomerDetail lForm,
> can_delete=True)
> # bla bla bla....
>
> if request.method == 'POST':
>
> find_formsetcustomerdetail = CustomerDetail .objects.filter(customerheader__id=id_unquekey)
> formset = q1(request.POST,request.FILES,queryset=find_formsetcustomerdetail)
> if formset.is_valid():
> for formline in formset:
> # do checking..bla bla bla
> formline.save()
>
> Regards,
> MH
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> 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.

Peter of the Norse
RahmCoff@Radio1190.org



--
You received this message because you are subscribed to the Google Groups "Django users" group.
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