I am saving the last time a page has been visited, and since I upgraded to Django 1.8, all my dates went wonky... And I really, really dont get it.
I basically have an API that is being poked by kiosk computers set all around the US, but I want to know if at a point in time the kiosk has checked in in the last 3 minutes or not. I don't care in which timezone it is.
I have a simple datetimefield:
lastcheckintime = models.DateTimeField(blank=True, null=True, auto_now=False)
And when the API is called, I simply save this:
monitor.lastcheckintime = timezone.now()
With a debug log, looks like it's saving the right UTC time in the database. I'm checkin if a monitor is online with this:
@property
def is_online(self):
if self.lastcheckintime is None:
return False
time_threshold = timezone.now() - timedelta(minutes=3)
return self.lastcheckintime > time_threshold
It used to be perfect until I upgraded. I can't tell if it's the upgrade of Django to 1.8 or pytz itself, but now it looks like this:
(In my timezone it's 10:29pm)
And the weird part is that these lines change ! It's not always the same monitor that's on the wrong time. Also, the whole thing is off by 7 hours (I'm GMT -7). Any other model looks to work correctly, I'm completely lost on why this one is behaving erratically.
Any idea on something I might have missed?
Thanks!