Ticket #5309: query.py.2.diff
File query.py.2.diff, 1.3 KB (added by , 17 years ago) |
---|
-
django/django/db/models/query.py
262 262 if len(obj_list) < 1: 263 263 raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name 264 264 assert len(obj_list) == 1, "get() returned more than one %s -- it returned %s! Lookup parameters were %s" % (self.model._meta.object_name, len(obj_list), kwargs) 265 return obj_list[0] 265 obj = obj_list[0] 266 obj._is_stored = True 267 return obj 266 268 267 269 def create(self, **kwargs): 268 270 """ … … 270 272 and returning the created object. 271 273 """ 272 274 obj = self.model(**kwargs) 275 obj._is_stored = False 273 276 obj.save() 274 277 return obj 275 278 … … 287 290 params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) 288 291 params.update(defaults) 289 292 obj = self.model(**params) 293 obj._is_stored = False 290 294 obj.save() 291 295 return obj, True 292 296 … … 1178 1182 setattr(instance, field.attname, None) 1179 1183 1180 1184 setattr(instance, cls._meta.pk.attname, None) 1185 instance._is_stored = False 1181 1186 dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance) 1182 1187 1183 1188 transaction.commit_unless_managed()