summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2009-06-11 18:59:48 +0000
committerBrian Rosner <brosner@gmail.com>2009-06-11 18:59:48 +0000
commita5e7d975940feda2c2d03201a1097d726448ec88 (patch)
tree799287a50e0ef8c1f30aac95bad38267bbffab71
parent4cb4086b2a16d6992fbffd2e8f15ae11b17412a7 (diff)
Fixed #11302 -- Avoid unnesscary (and possibly unintentional) queries/results from generic inline formsets.
When an instance with no primary key value is passed in to a generic inline formset we ensure no queries/results occur. Thanks Alex Gaynor. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/contenttypes/generic.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 5564548133..4df48ff9f5 100644
--- a/django/contrib/contenttypes/generic.py
+++ b/django/contrib/contenttypes/generic.py
@@ -317,7 +317,7 @@ class BaseGenericInlineFormSet(BaseModelFormSet):
def get_queryset(self):
# Avoid a circular import.
from django.contrib.contenttypes.models import ContentType
- if self.instance is None:
+ if self.instance is None or self.instance.pk is None:
return self.model._default_manager.none()
return self.model._default_manager.filter(**{
self.ct_field.name: ContentType.objects.get_for_model(self.instance),