python - Weird behavior of Django's timezone.now() -


i saving last time page has been visited, , since upgraded django 1.8, dates went wonky... , really, dont it.

i have api being poked kiosk computers set around us, want know if @ point in time kiosk has checked in in last 3 minutes or not. don't care in timezone is.

i have simple datetimefield:

lastcheckintime = models.datetimefield(blank=true, null=true, auto_now=false) 

and when api called, save this:

monitor.lastcheckintime = timezone.now() 

with debug log, looks it's saving right utc time in database. i'm checkin if monitor online this:

@property def is_online(self):     if self.lastcheckintime none:         return false      time_threshold = timezone.now() - timedelta(minutes=3)     return self.lastcheckintime > time_threshold 

it used perfect until upgraded. can't tell if it's upgrade of django 1.8 or pytz itself, looks this:

last 3 lines wonky

(in timezone it's 10:29pm)

and weird part these lines change ! it's not same monitor that's on wrong time. also, whole thing off 7 hours (i'm gmt -7). other model looks work correctly, i'm lost on why 1 behaving erratically.

any idea on might have missed?

thanks!

still can't understand happened, ended creating datetimefield exact properties , use 1 instead, delete old lastcheckintime , works fine.

this still mystery though... thanks!


Comments