Commits

dready committed 4a48ef8

fix DateTimeFilter to support Django 1.6 (issue #5)

  • Participants
  • Parent commits 34a9fb9

Comments (0)

Files changed (1)

django_easyfilters/filters.py

                 else:
                     range_type = YEAR
 
-            date_qs = qs.dates(self.field, range_type.label)
+            # API for `QuerySet.dates` used to return a list of `datetime` objects,
+            # but from Django 1.6 onwards, it returns a list of `date` objects instead.
+            # See: https://docs.djangoproject.com/en/1.6/releases/1.6/#queryset-dates-returns-date-objects
+            date_qs = (qs.datetimes(self.field, range_type.label) if hasattr(qs, 'datetimes') else
+                       qs.dates(self.field, range_type.label))
             results = date_aggregation(date_qs)
 
             date_choice_counts = self.collapse_results(results, range_type)