fix: Use timezone data not native datetime

This commit is contained in:
2024-10-29 17:50:29 +01:00
parent 23d8e85031
commit 1cd70228b9
2 changed files with 27 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
from datetime import datetime
from django.utils import timezone
from notfellchen.celery import app as celery_app
from .tools.admin import clean_locations, deactivate_unchecked_adoption_notices
from .tools.misc import healthcheck_ok
@@ -8,9 +8,9 @@ from .models import Location, AdoptionNotice, Timestamp
def set_timestamp(key: str):
try:
ts = Timestamp.objects.get(key=key)
ts.timestamp = datetime.now()
ts.timestamp = timezone.now()
except Timestamp.DoesNotExist:
Timestamp.objects.create(key=key, timestamp=datetime.now())
Timestamp.objects.create(key=key, timestamp=timezone.now())
@celery_app.task(name="admin.clean_locations")