Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use `LOOKUP_SEP` in `get_or_create`.

  • Loading branch information...
commit 356443fd956c45e66c24256edc8f673d773b6ac8 1 parent a98465c
Simon Charette charettes authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/db/models/query.py
4 django/db/models/query.py
View
@@ -466,14 +466,14 @@ def get_or_create(self, **kwargs):
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:
Please sign in to comment.
Something went wrong with that request. Please try again.