Use `LOOKUP_SEP` in `get_or_create`.

This commit is contained in:
Simon Charette 2013-04-18 01:55:12 -04:00
parent a98465c040
commit 356443fd95
1 changed files with 2 additions and 2 deletions

View File

@ -466,14 +466,14 @@ class QuerySet(object):
return self.get(**lookup), False return self.get(**lookup), False
except self.model.DoesNotExist: except self.model.DoesNotExist:
try: 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) params.update(defaults)
obj = self.model(**params) obj = self.model(**params)
sid = transaction.savepoint(using=self.db) sid = transaction.savepoint(using=self.db)
obj.save(force_insert=True, using=self.db) obj.save(force_insert=True, using=self.db)
transaction.savepoint_commit(sid, using=self.db) transaction.savepoint_commit(sid, using=self.db)
return obj, True return obj, True
except IntegrityError as e: except IntegrityError:
transaction.savepoint_rollback(sid, using=self.db) transaction.savepoint_rollback(sid, using=self.db)
exc_info = sys.exc_info() exc_info = sys.exc_info()
try: try: