ソースを参照

Closes #10820: Switch timezone library from pytz to zoneinfo

jeremystretch 3 年 前
コミット
3b0a84969b

+ 1 - 1
docs/models/dcim/site.md

@@ -33,7 +33,7 @@ Each site can have multiple [AS numbers](../ipam/asn.md) assigned to it.
 
 ### Time Zone
 
-The site's local time zone. (Time zones are provided by the [pytz](https://pypi.org/project/pytz/) package.)
+The site's local time zone. (Time zones are provided by the [zoneinfo](https://docs.python.org/3/library/zoneinfo.html) library.)
 
 ### Physical Address
 

+ 1 - 0
docs/release-notes/version-3.4.md

@@ -59,6 +59,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
 * [#10697](https://github.com/netbox-community/netbox/issues/10697) - Move application registry into core app
 * [#10699](https://github.com/netbox-community/netbox/issues/10699) - Remove custom `import_object()` function
 * [#10816](https://github.com/netbox-community/netbox/issues/10816) - Pass the current request when instantiating a FilterSet within UI views
+* [#10820](https://github.com/netbox-community/netbox/issues/10820) - Switch timezone library from pytz to zoneinfo
 
 ### REST API Changes
 

+ 3 - 4
netbox/dcim/tests/test_views.py

@@ -1,7 +1,7 @@
 from decimal import Decimal
 
-import pytz
 import yaml
+from backports.zoneinfo import ZoneInfo
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.models import ContentType
 from django.test import override_settings
@@ -12,7 +12,6 @@ from dcim.choices import *
 from dcim.constants import *
 from dcim.models import *
 from ipam.models import ASN, RIR, VLAN, VRF
-from netbox.api.serializers import GenericObjectSerializer
 from tenancy.models import Tenant
 from utilities.testing import ViewTestCases, create_tags, create_test_device, post_data
 from wireless.models import WirelessLAN
@@ -153,7 +152,7 @@ class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
             'tenant': None,
             'facility': 'Facility X',
             'asns': [asns[6].pk, asns[7].pk],
-            'time_zone': pytz.UTC,
+            'time_zone': ZoneInfo('UTC'),
             'description': 'Site description',
             'physical_address': '742 Evergreen Terrace, Springfield, USA',
             'shipping_address': '742 Evergreen Terrace, Springfield, USA',
@@ -182,7 +181,7 @@ class SiteTestCase(ViewTestCases.PrimaryObjectViewTestCase):
             'region': regions[1].pk,
             'group': groups[1].pk,
             'tenant': None,
-            'time_zone': pytz.timezone('US/Eastern'),
+            'time_zone': ZoneInfo('US/Eastern'),
             'description': 'New description',
         }
 

+ 0 - 1
netbox/netbox/settings.py

@@ -389,7 +389,6 @@ LANGUAGE_CODE = 'en-us'
 USE_I18N = True
 USE_L10N = False
 USE_TZ = True
-USE_DEPRECATED_PYTZ = True
 
 # WSGI
 WSGI_APPLICATION = 'netbox.wsgi.application'