Skip to content

Commit fd70591

Browse files
Refs #36152, #35667 -- Used skip_file_prefixes in alias deprecation warning.
Follow-up to 8ede411.
1 parent 23b6594 commit fd70591

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

django/db/models/sql/query.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import copy
1111
import difflib
1212
import functools
13-
import inspect
1413
import sys
1514
import warnings
1615
from collections import Counter, namedtuple
@@ -44,7 +43,7 @@
4443
from django.db.models.sql.constants import INNER, LOUTER, ORDER_DIR, SINGLE
4544
from django.db.models.sql.datastructures import BaseTable, Empty, Join, MultiJoin
4645
from django.db.models.sql.where import AND, OR, ExtraWhere, NothingNode, WhereNode
47-
from django.utils.deprecation import RemovedInDjango70Warning
46+
from django.utils.deprecation import RemovedInDjango70Warning, django_file_prefixes
4847
from django.utils.functional import cached_property
4948
from django.utils.regex_helper import _lazy_re_compile
5049
from django.utils.tree import Node
@@ -1216,15 +1215,10 @@ def join_parent_model(self, opts, model, alias, seen):
12161215
def check_alias(self, alias):
12171216
# RemovedInDjango70Warning: When the deprecation ends, remove.
12181217
if "%" in alias:
1219-
if "aggregate" in {frame.function for frame in inspect.stack()}:
1220-
stacklevel = 5
1221-
else:
1222-
# annotate(), alias(), and values().
1223-
stacklevel = 6
12241218
warnings.warn(
12251219
"Using percent signs in a column alias is deprecated.",
1226-
stacklevel=stacklevel,
12271220
category=RemovedInDjango70Warning,
1221+
skip_file_prefixes=django_file_prefixes(),
12281222
)
12291223
if FORBIDDEN_ALIAS_PATTERN.search(alias):
12301224
raise ValueError(

0 commit comments

Comments
 (0)