[Django] #35609: RemovedInDjango50Warning communications with changing the default USE_TZ

2 views
Skip to first unread message

Django

unread,
7:37 AM (12 hours ago) 7:37 AM
to django-...@googlegroups.com
#35609: RemovedInDjango50Warning communications with changing the default USE_TZ
-------------------------+------------------------------------------------
Reporter: froOzzy | Type: Cleanup/optimization
Status: new | Component: Core (System checks)
Version: 4.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+------------------------------------------------
Good afternoon
When starting Django, we found a Warning that cannot be corrected (it
continues to be displayed in the logs and terminal). This happens because
the settings are initialized more than once and the condition for
displaying the warning is incorrect, in my opinion. Example from code:


{{{
self._explicit_settings = set()
for setting in dir(mod):
if setting.isupper():
setting_value = getattr(mod, setting)

if setting in tuple_settings and not isinstance(
setting_value, (list, tuple)
):
raise ImproperlyConfigured(
"The %s setting must be a list or a tuple." %
setting
)
setattr(self, setting, setting_value)
self._explicit_settings.add(setting)

if self.USE_TZ is False and not self.is_overridden("USE_TZ"):
warnings.warn(
"The default value of USE_TZ will change from False to
True "
"in Django 5.0. Set USE_TZ to False in your project
settings "
"if you want to keep the current default behavior.",
category=RemovedInDjango50Warning,
)
}}}

When first initialized, **dir(mod)** contains

{{{
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__spec__']
}}}

During the second initialization, the project settings are already. This
doesn't affect how django works, but it can be confusing. It might be
worth replacing the warning condition:

{{{
def is_overridden(self, setting):
return setting in self._explicit_settings and
self._explicit_settings
}}}

Because the multitude **self._explicit_settings** may be empty due to a
condition **if setting.isupper():**
--
Ticket URL: <https://code.djangoproject.com/ticket/35609>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages