Ticket #8669: create-always-inserts.v3.diff
File create-always-inserts.v3.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/related.py
301 301 add.alters_data = True 302 302 303 303 def create(self, **kwargs): 304 new_obj = self.model(**kwargs) 305 self.add(new_obj) 306 return new_obj 304 # Update kwargs with the related object that this 305 # ForeignRelatedObjectsDescriptor knows about. 306 kwargs.update({rel_field.name: instance}) 307 return super(RelatedManager, self).create(**kwargs) 307 308 create.alters_data = True 308 309 309 310 def get_or_create(self, **kwargs): … … 405 406 # from the method lookup table, as we do with add and remove. 406 407 if through is not None: 407 408 raise AttributeError, "Cannot use create() on a ManyToManyField which specifies an intermediary model. Use %s's Manager instead." % through 408 new_obj = self.model(**kwargs) 409 new_obj.save() 409 new_obj = super(ManyRelatedManager, self).create(**kwargs) 410 410 self.add(new_obj) 411 411 return new_obj 412 412 create.alters_data = True -
django/contrib/contenttypes/generic.py
272 272 def create(self, **kwargs): 273 273 kwargs[self.content_type_field_name] = self.content_type 274 274 kwargs[self.object_id_field_name] = self.pk_val 275 obj = self.model(**kwargs) 276 obj.save() 277 return obj 275 return super(GenericRelatedObjectManager, self).create(**kwargs) 278 276 create.alters_data = True 279 277 280 278 return GenericRelatedObjectManager