Ticket #5309: query.py.diff
File query.py.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 obj = obj_list[0] 266 obj.is_stored = True 267 return obj 265 return obj_list[0] 268 266 269 267 def create(self, **kwargs): 270 268 """ … … 272 270 and returning the created object. 273 271 """ 274 272 obj = self.model(**kwargs) 275 obj.is_stored = False276 273 obj.save() 277 274 return obj 278 275 … … 290 287 params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) 291 288 params.update(defaults) 292 289 obj = self.model(**params) 293 obj.is_stored = False294 290 obj.save() 295 291 return obj, True 296 292 … … 1182 1178 setattr(instance, field.attname, None) 1183 1179 1184 1180 setattr(instance, cls._meta.pk.attname, None) 1185 instance.is_stored = False1186 1181 dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance) 1187 1182 1188 1183 transaction.commit_unless_managed()