From 88b7f8ac1e2c9c3f157be91b1b9b7c22a40d2a98 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 16 May 2022 21:39:10 -0700 Subject: [PATCH] Use zoneinfo instead of tz Co-Authored-By: Trenton Holmes <797416+stumpylog@users.noreply.github.com> --- src/documents/serialisers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index eee4f0f9c..db55226e2 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -2,8 +2,11 @@ import datetime import math import re +try: + import zoneinfo +except ImportError: + import backports.zoneinfo as zoneinfo import magic -from dateutil import tz from django.conf import settings from django.utils.text import slugify from django.utils.translation import gettext as _ @@ -224,7 +227,7 @@ class DocumentSerializer(DynamicFieldsModelSerializer): if "created_date" in validated_data and "created" not in validated_data: new_datetime = datetime.datetime.combine( validated_data.get("created_date"), - datetime.time(0, 0, 0, 0, tz.gettz(settings.TIME_ZONE)), + datetime.time(0, 0, 0, 0, zoneinfo.ZoneInfo(settings.TIME_ZONE)), ) instance.created = new_datetime instance.save()