From c38d5175f0d805a970983859912b604602de3945 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Tue, 16 Apr 2024 21:39:41 +0200 Subject: [PATCH] fix(history): make history timezone aware Closes: #789 --- apis_core/history/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apis_core/history/models.py b/apis_core/history/models.py index 366fce3fa..46740ceda 100644 --- a/apis_core/history/models.py +++ b/apis_core/history/models.py @@ -11,6 +11,7 @@ from django.db.models import UniqueConstraint, Q from django.db.models.functions import Lower from django.contrib.contenttypes.models import ContentType +from django.utils import timezone class APISHistoricalRecords(HistoricalRecords, GenericModel): @@ -122,7 +123,7 @@ class Meta: def save(self, *args, **kwargs) -> None: if self._history_date is None: - self._history_date = datetime.now() + self._history_date = timezone.now() return super().save(*args, **kwargs) def delete(self, *args, **kwargs) -> tuple[int, dict[str, int]]: