Ticket #16869: save_new_using_form_save.patch

File save_new_using_form_save.patch, 1.1 KB (added by pyriku, 13 years ago)
  • django/contrib/contenttypes/generic.py

     
    348348    def save_new(self, form, commit=True):
    349349        # Avoid a circular import.
    350350        from django.contrib.contenttypes.models import ContentType
    351         kwargs = {
    352             self.ct_field.get_attname(): ContentType.objects.get_for_model(self.instance).pk,
    353             self.ct_fk_field.get_attname(): self.instance.pk,
    354         }
    355         new_obj = self.model(**kwargs)
    356         return save_instance(form, new_obj, commit=commit)
     351        setattr(form.instance, self.ct_field.get_attname(),
     352                ContentType.objects.get_for_model(self.instance).pk)
     353        setattr(form.instance, self.ct_fk_field.get_attname(),
     354                self.instance.pk)
     355        return form.save(commit=commit)
    357356
    358357def generic_inlineformset_factory(model, form=ModelForm,
    359358                                  formset=BaseGenericInlineFormSet,
Back to Top