Ticket #10274: BaseGenericInlineFormSet.diff
File BaseGenericInlineFormSet.diff, 2.0 KB (added by , 16 years ago) |
---|
-
django/contrib/contenttypes/generic.py
307 307 # Avoid a circular import. 308 308 from django.contrib.contenttypes.models import ContentType 309 309 if self.instance is None: 310 return self.model._default_manager. empty()310 return self.model._default_manager.get_empty_query_set() 311 311 return self.model._default_manager.filter(**{ 312 312 self.ct_field.name: ContentType.objects.get_for_model(self.instance), 313 313 self.ct_fk_field.name: self.instance.pk, -
tests/modeltests/generic_relations/models.py
219 219 >>> from django.contrib.contenttypes.generic import generic_inlineformset_factory 220 220 221 221 >>> 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 222 228 >>> formset = GenericFormSet(instance=Animal()) 223 229 >>> for form in formset.forms: 224 230 ... print form.as_p()