Skip to content

Commit

Permalink
Fixed #11302 -- Avoid unnesscary (and possibly unintentional) queries…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
brosner committed Jun 11, 2009
1 parent 4cb4086 commit a5e7d97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/contenttypes/generic.py
Expand Up @@ -317,7 +317,7 @@ def get_default_prefix(cls):
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),
Expand Down

0 comments on commit a5e7d97

Please sign in to comment.