Ticket #8669: create-always-inserts.diff
File create-always-inserts.diff, 1.9 KB (added by , 16 years ago) |
---|
-
db/models/fields/related.py
294 294 def get_query_set(self): 295 295 return superclass.get_query_set(self).filter(**(self.core_filters)) 296 296 297 def add(self, *objs ):297 def add(self, *objs, force_insert=False, force_update=False): 298 298 for obj in objs: 299 299 setattr(obj, rel_field.name, instance) 300 obj.save( )300 obj.save(force_insert=force_insert, force_update=force_update) 301 301 add.alters_data = True 302 302 303 303 def create(self, **kwargs): 304 304 new_obj = self.model(**kwargs) 305 self.add(new_obj )305 self.add(new_obj, force_insert=True) 306 306 return new_obj 307 307 create.alters_data = True 308 308 … … 406 406 if through is not None: 407 407 raise AttributeError, "Cannot use create() on a ManyToManyField which specifies an intermediary model. Use %s's Manager instead." % through 408 408 new_obj = self.model(**kwargs) 409 new_obj.save( )409 new_obj.save(force_insert=True) 410 410 self.add(new_obj) 411 411 return new_obj 412 412 create.alters_data = True -
contrib/contenttypes/generic.py
273 273 kwargs[self.content_type_field_name] = self.content_type 274 274 kwargs[self.object_id_field_name] = self.pk_val 275 275 obj = self.model(**kwargs) 276 obj.save( )276 obj.save(force_insert=True) 277 277 return obj 278 278 create.alters_data = True 279 279