mirror of
https://github.com/django/django.git
synced 2025-08-07 12:28:18 +00:00
Refs #29125 -- Made Q.deconstruct() omit 'query_utils' in the path and _connector='AND' since it's a default value.
This commit is contained in:
parent
b95c49c954
commit
9ba3df8240
2 changed files with 8 additions and 9 deletions
|
@ -98,13 +98,16 @@ class Q(tree.Node):
|
|||
|
||||
def deconstruct(self):
|
||||
path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__)
|
||||
if path.startswith('django.db.models.query_utils'):
|
||||
path = path.replace('django.db.models.query_utils', 'django.db.models')
|
||||
args, kwargs = (), {}
|
||||
if len(self.children) == 1 and not isinstance(self.children[0], Q):
|
||||
child = self.children[0]
|
||||
kwargs = {child[0]: child[1]}
|
||||
else:
|
||||
args = tuple(self.children)
|
||||
kwargs = {'_connector': self.connector}
|
||||
if self.connector != self.default:
|
||||
kwargs = {'_connector': self.connector}
|
||||
if self.negated:
|
||||
kwargs['_negated'] = True
|
||||
return path, args, kwargs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue