From d4b3ecd58c6da7435edf4eb1c459a7930bace313 Mon Sep 17 00:00:00 2001 From: hancush Date: Thu, 8 Apr 2021 15:17:19 -0500 Subject: [PATCH] Add timezone to bill sponsorship sort callback, connects #259 --- councilmatic_core/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/councilmatic_core/models.py b/councilmatic_core/models.py index 90ac2d1..e0885c4 100644 --- a/councilmatic_core/models.py +++ b/councilmatic_core/models.py @@ -1,5 +1,6 @@ import datetime import os +import pytz from django.db import models from django.contrib.gis.db import models as geo_models @@ -98,7 +99,7 @@ def sponsorship_sort(sponsorship): ''' Sponsorships of bills without recent action dates should appear last. ''' - return sponsorship.bill.last_action_date or datetime.date(datetime.MINYEAR, 1, 1) + return sponsorship.bill.last_action_date or pytz.utc.localize(datetime.date(datetime.MINYEAR, 1, 1)) return sorted((s for s in primary_sponsorships), key=sponsorship_sort, reverse=True)