From 4bd24474c02a6f3c70e8111ac262fabf2fc5f454 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Mon, 23 Feb 2009 04:30:38 +0000 Subject: [PATCH] Fixed #10274 -- Fixed an embarrassing mistake in BaseGenericInlineFormSet.get_queryset. Thanks Zak Johnson for the report and akaihola for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9886 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/contenttypes/generic.py | 2 +- tests/modeltests/generic_relations/models.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index c294f74500..13e7cd7a39 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -307,7 +307,7 @@ class BaseGenericInlineFormSet(BaseModelFormSet): # Avoid a circular import. from django.contrib.contenttypes.models import ContentType if self.instance is None: - return self.model._default_manager.empty() + return self.model._default_manager.none() return self.model._default_manager.filter(**{ self.ct_field.name: ContentType.objects.get_for_model(self.instance), self.ct_fk_field.name: self.instance.pk, diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py index db5ae47581..e6c1ee243e 100644 --- a/tests/modeltests/generic_relations/models.py +++ b/tests/modeltests/generic_relations/models.py @@ -219,6 +219,11 @@ __test__ = {'API_TESTS':""" >>> from django.contrib.contenttypes.generic import generic_inlineformset_factory >>> GenericFormSet = generic_inlineformset_factory(TaggedItem, extra=1) +>>> formset = GenericFormSet() +>>> for form in formset.forms: +... print form.as_p() +

+

>>> formset = GenericFormSet(instance=Animal()) >>> for form in formset.forms: ... print form.as_p()