mirror of
https://github.com/django/django.git
synced 2025-04-27 02:34:38 +00:00
Refs #26029 -- Added LazySettings._show_deprecation_warning() hook.
This commit is contained in:
parent
829f4d1448
commit
d16079dd90
@ -154,19 +154,20 @@ class LazySettings(LazyObject):
|
|||||||
"""Return True if the settings have already been configured."""
|
"""Return True if the settings have already been configured."""
|
||||||
return self._wrapped is not empty
|
return self._wrapped is not empty
|
||||||
|
|
||||||
@property
|
def _show_deprecation_warning(self, message, category):
|
||||||
def USE_L10N(self):
|
|
||||||
stack = traceback.extract_stack()
|
stack = traceback.extract_stack()
|
||||||
# Show a warning if the setting is used outside of Django.
|
# Show a warning if the setting is used outside of Django.
|
||||||
# Stack index: -1 this line, -2 the LazyObject __getattribute__(),
|
# Stack index: -1 this line, -2 the property, -3 the
|
||||||
# -3 the caller.
|
# LazyObject __getattribute__(), -4 the caller.
|
||||||
filename, _, _, _ = stack[-3]
|
filename, _, _, _ = stack[-4]
|
||||||
if not filename.startswith(os.path.dirname(django.__file__)):
|
if not filename.startswith(os.path.dirname(django.__file__)):
|
||||||
warnings.warn(
|
warnings.warn(message, category, stacklevel=2)
|
||||||
USE_L10N_DEPRECATED_MSG,
|
|
||||||
RemovedInDjango50Warning,
|
@property
|
||||||
stacklevel=2,
|
def USE_L10N(self):
|
||||||
)
|
self._show_deprecation_warning(
|
||||||
|
USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning
|
||||||
|
)
|
||||||
return self.__getattr__("USE_L10N")
|
return self.__getattr__("USE_L10N")
|
||||||
|
|
||||||
# RemovedInDjango50Warning.
|
# RemovedInDjango50Warning.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user