Ticket #18751: ticket-18751.2.diff

File ticket-18751.2.diff, 2.0 KB (added by Simon Charette, 12 years ago)
  • django/forms/formsets.py

    diff --git a/django/forms/formsets.py b/django/forms/formsets.py
    index 4ea8dc4..27481ba 100644
    a b class BaseFormSet(StrAndUnicode):  
    252252    errors = property(_get_errors)
    253253
    254254    def _should_delete_form(self, form):
    255         # The way we lookup the value of the deletion field here takes
    256         # more code than we'd like, but the form's cleaned_data will
    257         # not exist if the form is invalid.
    258         field = form.fields[DELETION_FIELD_NAME]
    259         raw_value = form._raw_value(DELETION_FIELD_NAME)
    260         should_delete = field.clean(raw_value)
    261         return should_delete
     255        """
     256        Returns whether or not the form was marked for deletion
     257        """
     258        return form.cleaned_data.get(DELETION_FIELD_NAME, False)
    262259
    263260    def is_valid(self):
    264261        """
  • tests/modeltests/model_formsets/tests.py

    diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py
    index e28560b..682d5ea 100644
    a b class DeletionTests(TestCase):  
    3232            'form-0-DELETE': 'on',
    3333        }
    3434        formset = PoetFormSet(data, queryset=Poet.objects.all())
    35         formset.save()
    3635        self.assertTrue(formset.is_valid())
     36        formset.save()
    3737        self.assertEqual(Poet.objects.count(), 0)
    3838
    3939    def test_add_form_deletion_when_invalid(self):
  • tests/regressiontests/inline_formsets/tests.py

    diff --git a/tests/regressiontests/inline_formsets/tests.py b/tests/regressiontests/inline_formsets/tests.py
    index 6e63f34..970ddcc 100644
    a b class DeletionTests(TestCase):  
    2323            'poem_set-0-DELETE': 'on',
    2424        }
    2525        formset = PoemFormSet(data, instance=poet)
    26         formset.save()
    2726        self.assertTrue(formset.is_valid())
     27        formset.save()
    2828        self.assertEqual(Poem.objects.count(), 0)
    2929
    3030    def test_add_form_deletion_when_invalid(self):
Back to Top