From 4cf989e5b5c97966d50d40395f6c0f28517e229b Mon Sep 17 00:00:00 2001 From: lizerk Date: Fri, 20 Mar 2026 00:21:04 +0300 Subject: [PATCH] Fix _UtcCompat: add missing normalize() method - ldapdb calls timezone.utc.normalize() for datetime field conversion - Added normalize() method that works the same as localize() for UTC - Fixes AttributeError: '_UtcCompat' object has no attribute 'normalize' --- backend/employees/ldap/orm_models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/employees/ldap/orm_models.py b/backend/employees/ldap/orm_models.py index 2e964d94..52b9faa6 100644 --- a/backend/employees/ldap/orm_models.py +++ b/backend/employees/ldap/orm_models.py @@ -109,13 +109,17 @@ if not hasattr(_dj_tz, 'utc'): """pytz-compatible UTC wrapper for django-ldapdb. Acts as a tzinfo subclass but delegates to datetime.timezone.utc - and provides the localize() method for pytz compatibility. + and provides pytz-compatible methods: localize() and normalize(). """ def localize(self, dt): """pytz-style localize method.""" return dt.replace(tzinfo=_dt.timezone.utc) + def normalize(self, dt): + """pytz-style normalize method - same as localize for UTC.""" + return dt.replace(tzinfo=_dt.timezone.utc) + def utcoffset(self, dt): return _dt.timedelta(0)