Ticket #13906: 13906_get_or_create.diff
File 13906_get_or_create.diff, 876 bytes (added by , 13 years ago) |
---|
-
django/db/models/query.py
367 367 lookup[f.name] = lookup.pop(f.attname) 368 368 try: 369 369 self._for_write = True 370 sid = transaction.savepoint(using=self.db) 370 371 return self.get(**lookup), False 371 372 except self.model.DoesNotExist: 372 373 try: 373 374 params = dict([(k, v) for k, v in kwargs.items() if '__' not in k]) 374 375 params.update(defaults) 375 376 obj = self.model(**params) 376 sid = transaction.savepoint(using=self.db)377 377 obj.save(force_insert=True, using=self.db) 378 378 transaction.savepoint_commit(sid, using=self.db) 379 379 return obj, True