Use now() instead of utcnow()

This commit is contained in:
Raphael Michel
2023-02-15 15:05:13 +01:00
parent b094c6861d
commit 6c7415a7ff

View File

@@ -26,6 +26,7 @@ import requests
from django.conf import settings from django.conf import settings
from django.db.models import Max from django.db.models import Max
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from lxml import etree from lxml import etree
@@ -57,7 +58,7 @@ def fetch_rates(sender, **kwargs):
continue continue
last_fetch_date = ExchangeRate.objects.filter(source=source_name).aggregate(m=Max('updated'))['m'] last_fetch_date = ExchangeRate.objects.filter(source=source_name).aggregate(m=Max('updated'))['m']
if last_fetch_date and last_fetch_date >= datetime.utcnow() - timedelta(hours=1): if last_fetch_date and last_fetch_date >= now() - timedelta(hours=1):
# Only try to fetch once per hour # Only try to fetch once per hour
continue continue