mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #16865 -- Made get_or_create use read database for initial get query.
Thanks Rick van Hattem for the report and trbs for the patch.
This commit is contained in:
parent
44767f2caf
commit
901af86550
3 changed files with 34 additions and 1 deletions
|
@ -455,9 +455,9 @@ class QuerySet(object):
|
|||
if f.attname in lookup:
|
||||
lookup[f.name] = lookup.pop(f.attname)
|
||||
try:
|
||||
self._for_write = True
|
||||
return self.get(**lookup), False
|
||||
except self.model.DoesNotExist:
|
||||
self._for_write = True
|
||||
try:
|
||||
params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
|
||||
params.update(defaults)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue