Browse Source

Refs #32379 -- Changed default USE_TZ to True.

Per deprecation timeline.
Mariusz Felisiak 2 years ago
parent
commit
602d9a312f

+ 0 - 8
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)
 

+ 1 - 1
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

+ 3 - 9
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 <startproject>` includes
-    ``USE_TZ = True`` for convenience.
+    In older versions, the default value is ``False``.
 
 .. setting:: USE_X_FORWARDED_HOST
 

+ 3 - 0
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.
 

+ 4 - 10
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 <USE_TZ>` in your settings file.
+Time zone support is enabled by default. To disable it, set :setting:`USE_TZ =
+False <USE_TZ>` 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 <startproject>` includes :setting:`USE_TZ = True <USE_TZ>`
-    for convenience.
-
 If you're wrestling with a particular problem, start with the :ref:`time zone
 FAQ <time-zones-faq>`.
 

+ 0 - 16
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(