mirror of
https://github.com/django/django.git
synced 2025-05-04 06:04:38 +00:00
Simplified QuerySet.update_or_create() a bit.
This commit is contained in:
parent
7bba231b67
commit
1081d24f99
@ -970,10 +970,10 @@ class QuerySet(AltersData):
|
|||||||
Return a tuple (object, created), where created is a boolean
|
Return a tuple (object, created), where created is a boolean
|
||||||
specifying whether an object was created.
|
specifying whether an object was created.
|
||||||
"""
|
"""
|
||||||
if create_defaults is None:
|
|
||||||
update_defaults = create_defaults = defaults or {}
|
|
||||||
else:
|
|
||||||
update_defaults = defaults or {}
|
update_defaults = defaults or {}
|
||||||
|
if create_defaults is None:
|
||||||
|
create_defaults = update_defaults
|
||||||
|
|
||||||
self._for_write = True
|
self._for_write = True
|
||||||
with transaction.atomic(using=self.db):
|
with transaction.atomic(using=self.db):
|
||||||
# Lock the row so that a concurrent update is blocked until
|
# Lock the row so that a concurrent update is blocked until
|
||||||
|
Loading…
x
Reference in New Issue
Block a user