Opened 13 years ago
Closed 13 years ago
#17077 closed Bug (duplicate)
deleting empty row in formset
Reported by: | Sergiy Kuzmenko | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | form, formset, validation |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If in a formset user marks empty row for deletion, form validation succeeds but retrieving cleaned_data fails. How to replicate:
>>> from django import forms >>> from django.forms.formsets import formset_factory >>> class ArticleForm(forms.Form): ... title = forms.CharField() ... pub_date = forms.DateField() ... >>> ArticleFormSet = formset_factory(ArticleForm, extra=1, can_delete=True) >>> data = { ... 'form-TOTAL_FORMS': u'2', ... 'form-INITIAL_FORMS': u'0', ... 'form-MAX_NUM_FORMS': u'', ... 'form-0-title': u'Test', ... 'form-0-pub_date': u'1904-06-16', ... 'form-0-DELETE': u'', ... 'form-1-title': u'', ... 'form-1-pub_date' : u'', ... 'form-1-DELETE' : 'o', ... } >>> >>> formset = ArticleFormSet(data) >>> formset.is_valid() True >>> formset.cleaned_data Traceback (most recent call last): File "<console>", line 1, in <module> File "D:\work\src\django-svn\trunk\django\forms\formsets.py", line 164, in _get_cleaned_data return [form.cleaned_data for form in self.forms] AttributeError: 'ArticleForm' object has no attribute 'cleaned_data'
Suggested behaviour: accept and ignore empty line deletion.
Note:
See TracTickets
for help on using tickets.
Already reported on #10828