Skip to content

Commit

Permalink
Fixed django#10274 -- Fixed an embarrassing mistake in BaseGenericInl…
Browse files Browse the repository at this point in the history
…ineFormSet.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
  • Loading branch information
brosner committed Feb 23, 2009
1 parent 13d3d9d commit 4bd2447
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/contrib/contenttypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def get_queryset(self):
# 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,
Expand Down
5 changes: 5 additions & 0 deletions tests/modeltests/generic_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ def __unicode__(self):
>>> 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()
<p><label for="id_generic_relations-taggeditem-content_type-object_id-0-tag">Tag:</label> <input id="id_generic_relations-taggeditem-content_type-object_id-0-tag" type="text" name="generic_relations-taggeditem-content_type-object_id-0-tag" maxlength="50" /></p>
<p><label for="id_generic_relations-taggeditem-content_type-object_id-0-DELETE">Delete:</label> <input type="checkbox" name="generic_relations-taggeditem-content_type-object_id-0-DELETE" id="id_generic_relations-taggeditem-content_type-object_id-0-DELETE" /><input type="hidden" name="generic_relations-taggeditem-content_type-object_id-0-id" id="id_generic_relations-taggeditem-content_type-object_id-0-id" /></p>
>>> formset = GenericFormSet(instance=Animal())
>>> for form in formset.forms:
... print form.as_p()
Expand Down

0 comments on commit 4bd2447

Please sign in to comment.