#12697: Prevent deletion of some rows in a formset
-----------------------------+------------------------------------
Reporter: shadfc | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Comment (by darklow):
I found a very easy solution for this problem to avoid unwanted deletion
of some inlines
You can just override delete_forms property method.
{{{
class MyInlineFormSet(BaseInlineFormSet):
@property
def deleted_forms(self):
deleted_forms = super(MyInlineFormSet, self).deleted_forms
for i, form in enumerate(deleted_forms):
if some_criteria_to_prevent_deletion:
deleted_forms.pop(i)
return deleted_forms
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/12697#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.03b5401266c3661f4627cfff5ca2e176%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.