Ticket #10274: 10274-generic-inline-formset-patch-and-test.diff

File 10274-generic-inline-formset-patch-and-test.diff, 2.0 KB (added by Antti Kaihola, 16 years ago)

patch and tests with none() instead of empty()

  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    index c294f74..13e7cd7 100644
    a b class BaseGenericInlineFormSet(BaseModelFormSet):  
    307307        # Avoid a circular import.
    308308        from django.contrib.contenttypes.models import ContentType
    309309        if self.instance is None:
    310             return self.model._default_manager.empty()
     310            return self.model._default_manager.none()
    311311        return self.model._default_manager.filter(**{
    312312            self.ct_field.name: ContentType.objects.get_for_model(self.instance),
    313313            self.ct_fk_field.name: self.instance.pk,
  • tests/modeltests/generic_relations/models.py

    diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py
    index db5ae47..e6c1ee2 100644
    a b __test__ = {'API_TESTS':"""  
    219219>>> from django.contrib.contenttypes.generic import generic_inlineformset_factory
    220220
    221221>>> GenericFormSet = generic_inlineformset_factory(TaggedItem, extra=1)
     222>>> formset = GenericFormSet()
     223>>> for form in formset.forms:
     224...     print form.as_p()
     225<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>
     226<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>
    222227>>> formset = GenericFormSet(instance=Animal())
    223228>>> for form in formset.forms:
    224229...     print form.as_p()
Back to Top