Ticket #12577: inline.diff

File inline.diff, 983 bytes (added by raffaele.salmaso@…, 15 years ago)

reenable the save_new in BaseGenericInlineFormSet

  • django/contrib/contenttypes/generic.py

    diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
    a b  
    342342        setattr(form.instance, self.ct_field.attname, ContentType.objects.get_for_model(self.instance).pk)
    343343        return form
    344344
     345    def save_new(self, form, commit=True):
     346        # Avoid a circular import.
     347        from django.contrib.contenttypes.models import ContentType
     348        kwargs = {
     349            self.ct_field.get_attname(): ContentType.objects.get_for_model(self.instance).pk,
     350            self.ct_fk_field.get_attname(): self.instance.pk,
     351        }
     352        new_obj = self.model(**kwargs)
     353        return save_instance(form, new_obj, commit=commit)
     354
    345355def generic_inlineformset_factory(model, form=ModelForm,
    346356                                  formset=BaseGenericInlineFormSet,
    347357                                  ct_field="content_type", fk_field="object_id",
Back to Top