Ticket #16869: save_new_using_form_save.patch
File save_new_using_form_save.patch, 1.1 KB (added by , 13 years ago) |
---|
-
django/contrib/contenttypes/generic.py
348 348 def save_new(self, form, commit=True): 349 349 # Avoid a circular import. 350 350 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) 357 356 358 357 def generic_inlineformset_factory(model, form=ModelForm, 359 358 formset=BaseGenericInlineFormSet,