summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2024-12-29 03:14:41 -0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-03 08:40:13 +0100
commitc3a681659c4a982101ffee0d3ef205ac5b310e17 (patch)
tree4cb75cc47d44b77b44baf405bc2b4d9b8b38504e /django/db/models/sql/query.py
parent45dc2aaa2a9dfe6d7d706f5e9f6757318423602e (diff)
Fixed #36029 -- Handled implicit exact lookups in condition depth checks for FilteredRelation.
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index cca11bfcc2..6fbf854e67 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1704,12 +1704,12 @@ class Query(BaseExpression):
"relations outside the %r (got %r)."
% (filtered_relation.relation_name, lookup)
)
- else:
- raise ValueError(
- "FilteredRelation's condition doesn't support nested "
- "relations deeper than the relation_name (got %r for "
- "%r)." % (lookup, filtered_relation.relation_name)
- )
+ if len(lookup_field_parts) > len(relation_field_parts) + 1:
+ raise ValueError(
+ "FilteredRelation's condition doesn't support nested "
+ "relations deeper than the relation_name (got %r for "
+ "%r)." % (lookup, filtered_relation.relation_name)
+ )
filtered_relation.condition = rename_prefix_from_q(
filtered_relation.relation_name,
alias,