diff --git a/django/forms/formsets.py b/django/forms/formsets.py
a
|
b
|
|
60 | 60 | def __len__(self): |
61 | 61 | return len(self.forms) |
62 | 62 | |
| 63 | def __nonzero__(self): |
| 64 | """All formsets have a management form which is not included in the length""" |
| 65 | return True |
| 66 | |
63 | 67 | def _management_form(self): |
64 | 68 | """Returns the ManagementForm instance for this FormSet.""" |
65 | 69 | if self.is_bound: |
diff --git a/tests/regressiontests/forms/tests/formsets.py b/tests/regressiontests/forms/tests/formsets.py
a
|
b
|
|
805 | 805 | self.assertEqual(str(reverse_formset[1]), str(forms[-2])) |
806 | 806 | self.assertEqual(len(reverse_formset), len(forms)) |
807 | 807 | |
| 808 | def test_formset_nonzero(self): |
| 809 | """ |
| 810 | Formsets with no forms should still evaluate as true. |
| 811 | Regression test for #15722 |
| 812 | """ |
| 813 | ChoiceFormset = formset_factory(Choice, extra=0) |
| 814 | formset = ChoiceFormset() |
| 815 | self.assertEqual(len(formset.forms), 0) |
| 816 | self.assertTrue(formset) |
| 817 | |
| 818 | |
808 | 819 | data = { |
809 | 820 | 'choices-TOTAL_FORMS': '1', # the number of forms rendered |
810 | 821 | 'choices-INITIAL_FORMS': '0', # the number of forms with initial data |