summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarosław Wygoda <jaroslaw@wygoda.me>2023-01-11 09:00:22 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-11 09:02:01 +0100
commitd16079dd90320141c2024809ba0fce43f0f2cb02 (patch)
treeac7a87d8973f30cceecb61561681ad526f7470f5
parent829f4d1448f7b40238b47592fc17061bf77b0f23 (diff)
Refs #26029 -- Added LazySettings._show_deprecation_warning() hook.
-rw-r--r--django/conf/__init__.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index cb70a71791..7636239697 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -154,19 +154,20 @@ class LazySettings(LazyObject):
"""Return True if the settings have already been configured."""
return self._wrapped is not empty
- @property
- def USE_L10N(self):
+ def _show_deprecation_warning(self, message, category):
stack = traceback.extract_stack()
# Show a warning if the setting is used outside of Django.
- # Stack index: -1 this line, -2 the LazyObject __getattribute__(),
- # -3 the caller.
- filename, _, _, _ = stack[-3]
+ # Stack index: -1 this line, -2 the property, -3 the
+ # LazyObject __getattribute__(), -4 the caller.
+ filename, _, _, _ = stack[-4]
if not filename.startswith(os.path.dirname(django.__file__)):
- warnings.warn(
- USE_L10N_DEPRECATED_MSG,
- RemovedInDjango50Warning,
- stacklevel=2,
- )
+ warnings.warn(message, category, stacklevel=2)
+
+ @property
+ def USE_L10N(self):
+ self._show_deprecation_warning(
+ USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning
+ )
return self.__getattr__("USE_L10N")
# RemovedInDjango50Warning.