File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11from django import forms
22
3+
4+ # https://code.djangoproject.com/ticket/19917
5+ class Django14TimeField (forms .TimeField ):
6+ input_formats = ['%H:%M:%S' , '%H:%M:%S.%f' , '%H:%M' ]
7+
8+
39class ArrayDecimalField (forms .DecimalField ):
410 def clean (self , value ):
511 if value is None :
Original file line number Diff line number Diff line change 11from __future__ import absolute_import
22from __future__ import unicode_literals
33
4+ import django
45from django .utils import six
56from django_filters .filters import *
67
@@ -33,6 +34,11 @@ class AllLookupsFilter(Filter):
3334# Fixed-up versions of some of the default filters
3435###################################################
3536
37+ class TimeFilter (TimeFilter ):
38+ if django .VERSION < (1 , 6 ):
39+ field_class = fields .Django14TimeField
40+
41+
3642class InSetNumberFilter (NumberFilter ):
3743 field_class = fields .ArrayDecimalField
3844
Original file line number Diff line number Diff line change 2424
2525
2626class FilterSet (django_filters .FilterSet ):
27- # In order to support ISO-8601 -- which is the default output for
28- # DRF -- we need to set up custom date/time input formats.
2927 filter_overrides = {
28+
29+ # In order to support ISO-8601 -- which is the default output for
30+ # DRF -- we need to use django-filter's IsoDateTimeFilter
3031 models .DateTimeField : {
3132 'filter_class' : filters .IsoDateTimeFilter ,
3233 },
34+
35+ # Django < 1.6 time input formats did not account for microseconds
36+ # https://code.djangoproject.com/ticket/19917
37+ models .TimeField : {
38+ 'filter_class' : filters .TimeFilter ,
39+ }
3340 }
3441
3542 LOOKUP_TYPES = django_filters .filters .LOOKUP_TYPES
You can’t perform that action at this time.
0 commit comments