diff --git a/django/conf/__init__.py b/django/conf/__init__.py index 7849abbdbb2..b872230f969 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -237,14 +237,6 @@ class Settings: 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, - ) - if self.is_overridden("USE_DEPRECATED_PYTZ"): warnings.warn(USE_DEPRECATED_PYTZ_DEPRECATED_MSG, RemovedInDjango50Warning) diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 7ca9d6c4583..e946b47d8f6 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -41,7 +41,7 @@ ALLOWED_HOSTS = [] TIME_ZONE = "America/Chicago" # If you set this to True, Django will use timezone-aware datetimes. -USE_TZ = False +USE_TZ = True # RemovedInDjango50Warning: It's a transitional setting helpful in migrating # from pytz tzinfo to ZoneInfo(). Set True to continue using pytz tzinfo diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 4a1891de4e1..777dc18c50a 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -2929,11 +2929,7 @@ See also :setting:`DECIMAL_SEPARATOR`, :setting:`NUMBER_GROUPING` and ``USE_TZ`` ---------- -Default: ``False`` - -.. note:: - - In Django 5.0, the default value will change from ``False`` to ``True``. +Default: ``True`` A boolean that specifies if datetimes will be timezone-aware by default or not. If this is set to ``True``, Django will use timezone-aware datetimes internally. @@ -2944,11 +2940,9 @@ be retained if present. See also :setting:`TIME_ZONE`, :setting:`USE_I18N` and :setting:`USE_L10N`. -.. note:: +.. versionchanged:: 5.0 - The default :file:`settings.py` file created by - :djadmin:`django-admin startproject ` includes - ``USE_TZ = True`` for convenience. + In older versions, the default value is ``False``. .. setting:: USE_X_FORWARDED_HOST diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index 631a11ca3bc..f90e2f763e5 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -261,6 +261,9 @@ to remove usage of these features. * The undocumented ``django.utils.datetime_safe`` module is removed. +* The default value of the ``USE_TZ`` setting is changed from ``False`` to + ``True``. + See :ref:`deprecated-features-4.1` for details on these changes, including how to remove usage of these features. diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt index bfc1b77a3fd..c0063eb12d0 100644 --- a/docs/topics/i18n/timezones.txt +++ b/docs/topics/i18n/timezones.txt @@ -24,23 +24,17 @@ or under bill your customers by one hour, twice a year, every year. The solution to this problem is to use UTC in the code and use local time only when interacting with end users. -Time zone support is disabled by default. To enable it, set :setting:`USE_TZ = -True ` in your settings file. +Time zone support is enabled by default. To disable it, set :setting:`USE_TZ = +False ` in your settings file. -.. note:: +.. versionchanged:: 5.0 - In Django 5.0, time zone support will be enabled by default. + In older version, time zone support was disabled by default. Time zone support uses :mod:`zoneinfo`, which is part of the Python standard library from Python 3.9. The ``backports.zoneinfo`` package is automatically installed alongside Django if you are using Python 3.8. -.. note:: - - The default :file:`settings.py` file created by :djadmin:`django-admin - startproject ` includes :setting:`USE_TZ = True ` - for convenience. - If you're wrestling with a particular problem, start with the :ref:`time zone FAQ `. diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py index f9ea7700bb1..32a9c6cc19d 100644 --- a/tests/settings_tests/tests.py +++ b/tests/settings_tests/tests.py @@ -348,25 +348,9 @@ class SettingsTests(SimpleTestCase): with self.assertRaisesMessage(ValueError, "Incorrect timezone setting: test"): settings._setup() - def test_use_tz_false_deprecation(self): - settings_module = ModuleType("fake_settings_module") - settings_module.SECRET_KEY = "foo" - sys.modules["fake_settings_module"] = settings_module - msg = ( - "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." - ) - try: - with self.assertRaisesMessage(RemovedInDjango50Warning, msg): - Settings("fake_settings_module") - finally: - del sys.modules["fake_settings_module"] - def test_use_deprecated_pytz_deprecation(self): settings_module = ModuleType("fake_settings_module") settings_module.USE_DEPRECATED_PYTZ = True - settings_module.USE_TZ = True sys.modules["fake_settings_module"] = settings_module try: with self.assertRaisesMessage(