Use `LOOKUP_SEP` in `get_or_create`.
This commit is contained in:
parent
a98465c040
commit
356443fd95
|
@ -466,14 +466,14 @@ class QuerySet(object):
|
|||
return self.get(**lookup), False
|
||||
except self.model.DoesNotExist:
|
||||
try:
|
||||
params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
|
||||
params = dict((k, v) for k, v in kwargs.items() if LOOKUP_SEP not in k)
|
||||
params.update(defaults)
|
||||
obj = self.model(**params)
|
||||
sid = transaction.savepoint(using=self.db)
|
||||
obj.save(force_insert=True, using=self.db)
|
||||
transaction.savepoint_commit(sid, using=self.db)
|
||||
return obj, True
|
||||
except IntegrityError as e:
|
||||
except IntegrityError:
|
||||
transaction.savepoint_rollback(sid, using=self.db)
|
||||
exc_info = sys.exc_info()
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue