summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2025-09-18 15:50:35 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2025-09-19 14:38:07 -0400
commitfd705912fff168d10c806568a222dfa25e3bb6a0 (patch)
treed76b0cf4c2174098dc46143f4a6f0c1f19c30d45
parent23b659402663dace32a04a0bf15dd13e5bfadc7e (diff)
Refs #36152, #35667 -- Used skip_file_prefixes in alias deprecation warning.
Follow-up to 8ede411a81b40ca53362e6788601193c7e56a0cf.
-rw-r--r--django/db/models/sql/query.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index f0865f5f78..fb1f831042 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -10,7 +10,6 @@ all about the internals of models in order to get the information it needs.
import copy
import difflib
import functools
-import inspect
import sys
import warnings
from collections import Counter, namedtuple
@@ -44,7 +43,7 @@ from django.db.models.query_utils import (
from django.db.models.sql.constants import INNER, LOUTER, ORDER_DIR, SINGLE
from django.db.models.sql.datastructures import BaseTable, Empty, Join, MultiJoin
from django.db.models.sql.where import AND, OR, ExtraWhere, NothingNode, WhereNode
-from django.utils.deprecation import RemovedInDjango70Warning
+from django.utils.deprecation import RemovedInDjango70Warning, django_file_prefixes
from django.utils.functional import cached_property
from django.utils.regex_helper import _lazy_re_compile
from django.utils.tree import Node
@@ -1216,15 +1215,10 @@ class Query(BaseExpression):
def check_alias(self, alias):
# RemovedInDjango70Warning: When the deprecation ends, remove.
if "%" in alias:
- if "aggregate" in {frame.function for frame in inspect.stack()}:
- stacklevel = 5
- else:
- # annotate(), alias(), and values().
- stacklevel = 6
warnings.warn(
"Using percent signs in a column alias is deprecated.",
- stacklevel=stacklevel,
category=RemovedInDjango70Warning,
+ skip_file_prefixes=django_file_prefixes(),
)
if FORBIDDEN_ALIAS_PATTERN.search(alias):
raise ValueError(