replace timezone with datetime

Since the plots are not really part of django they aren't returning timezone
objects which django can convert to the correct timezone. Therefore they are
always UTC. However we can disable the timezone support in django. The're might
be a more elegant solution to this but since this is just a small project I'll
leave it at that.
This commit is contained in:
Andreas Zweili 2019-10-21 19:42:03 +02:00
parent e0edc6e113
commit 2c5bac292a
3 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import os
from django.utils import timezone
from datetime import datetime
if os.uname()[4].startswith("arm"):
from sense_hat import SenseHat
@ -27,7 +27,7 @@ def get_humidity():
def values_to_db():
time = timezone.now()
time = datetime.now()
Temperature.objects.create(value=get_temperature(), time=time)
Humidity.objects.create(value=get_humidity(), time=time)
Pressure.objects.create(value=get_pressure(), time=time)

View File

@ -1,11 +1,11 @@
from datetime import timedelta
from django.utils import timezone
from datetime import datetime
from plotly.offline import plot
from plotly.graph_objs import Scatter
from collector.models import Temperature, Humidity, Pressure
start_time = timezone.now() - timedelta(hours=12)
start_time = datetime.now() - timedelta(hours=12)
def temperature():
data = Temperature.objects.filter(time__gt=start_time)

View File

@ -95,7 +95,7 @@ USE_I18N = True
USE_L10N = True
USE_TZ = True
USE_TZ = False
# Static files (CSS, JavaScript, Images)