Ticket #10274: BaseGenericInlineFormSet.diff

File BaseGenericInlineFormSet.diff, 2.0 KB (added by Zak Johnson <zakj@…>, 16 years ago)
  • django/contrib/contenttypes/generic.py

     
    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.get_empty_query_set()
    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

     
    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>
     227
    222228>>> formset = GenericFormSet(instance=Animal())
    223229>>> for form in formset.forms:
    224230...     print form.as_p()
Back to Top