summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-03-27 14:47:12 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-06-13 18:08:06 +0200
commit84ed3cfb40a64e64ddc32cc0df943cb12e198717 (patch)
treed4220a3a19ee6ae31fbf281d7e0d35fb5b452cd1 /ishtar_common/utils.py
parentdb174e7f376a3687cb6cd84339592231ceae0ee0 (diff)
downloadIshtar-84ed3cfb40a64e64ddc32cc0df943cb12e198717.tar.bz2
Ishtar-84ed3cfb40a64e64ddc32cc0df943cb12e198717.zip
♻️ django: fix warnings for v5 - migrate to timezone aware dates
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 5dcfc119c..baaa25c95 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -70,6 +70,7 @@ from django.db.models import Q
from django.db.models.functions import Length
from django.http import HttpResponseRedirect
from django.urls import re_path, reverse, NoReverseMatch
+from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.datastructures import MultiValueDict as BaseMultiValueDict
from django.utils.formats import date_format
@@ -937,7 +938,7 @@ def get_file_from_link(file_link):
def get_current_year():
- return datetime.datetime.now().year
+ return datetime.date.today().year
def get_cache(cls, extra_args=tuple(), app_label=None):
@@ -2378,7 +2379,7 @@ def m2m_historization_changed(sender, **kwargs):
if q.count():
hist = q.all()[0]
hist.history_m2m = hist_values
- hist.history_date = hist.last_modified = datetime.datetime.now()
+ hist.history_date = hist.last_modified = timezone.now()
hist.save()
obj.skip_history_when_saving = True
elif not obj.history_modifier:
@@ -2959,7 +2960,7 @@ def duplicate_item(item, user=None, data=None):
def get_image_path(instance, filename):
# when using migrations instance is not a real ImageModel instance
if not hasattr(instance, "_get_image_path"):
- n = datetime.datetime.now()
+ n = datetime.date.today()
return "upload/{}/{:02d}/{:02d}/{}".format(n.year, n.month, n.day, filename)
return instance._get_image_path(filename)