fix: Use timezone data not native datetime

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

View File

@ -0,0 +1,24 @@
# Generated by Django 5.1.1 on 2024-10-29 10:44
import django.utils.timezone
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('fellchensammlung', '0010_timestamp'),
]
operations = [
migrations.AlterField(
model_name='adoptionnotice',
name='created_at',
field=models.DateField(default=django.utils.timezone.now, verbose_name='Erstellt am'),
),
migrations.AlterField(
model_name='adoptionnotice',
name='last_checked',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Zuletzt überprüft am'),
),
]

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")