diff --git a/django/forms/models.py b/django/forms/models.py
index 15d5041..cd8f027 100644
a
|
b
|
class BaseModelFormSet(BaseFormSet):
|
591 | 591 | def save_existing_objects(self, commit=True): |
592 | 592 | self.changed_objects = [] |
593 | 593 | self.deleted_objects = [] |
594 | | if not self.get_queryset(): |
| 594 | if not self.initial_forms: |
595 | 595 | return [] |
596 | 596 | |
597 | 597 | saved_instances = [] |
diff --git a/tests/regressiontests/model_formsets_regress/tests.py b/tests/regressiontests/model_formsets_regress/tests.py
index 613d776..f1e935e 100644
a
|
b
|
class FormsetTests(TestCase):
|
249 | 249 | self.assertEqual(formset.extra_forms[0].initial['username'], "apollo11") |
250 | 250 | self.assertTrue(u'value="apollo12"' in formset.extra_forms[1].as_p()) |
251 | 251 | |
| 252 | def test_extraneous_query_is_not_run(self): |
| 253 | Formset = modelformset_factory(Network) |
| 254 | data = {u'test-TOTAL_FORMS': u'1', |
| 255 | u'test-INITIAL_FORMS': u'0', |
| 256 | u'test-MAX_NUM_FORMS': u'', |
| 257 | u'test-0-name': u'Random Place', } |
| 258 | with self.assertNumQueries(1): |
| 259 | formset = Formset(data, prefix="test") |
| 260 | formset.save() |
| 261 | |
| 262 | |
252 | 263 | class CustomWidget(forms.CharField): |
253 | 264 | pass |
254 | 265 | |