class AllFiltersFilterSet(FilterSet): number_AllValuesFilter = AllValuesFilter(field_name='number', lookup_expr='exact') number_AllValuesMultipleFilter_OR = AllValuesMultipleFilter(field_name='number', lookup_expr='exact', conjoined=False) # OR number_AllValuesMultipleFilter_AND = AllValuesMultipleFilter(field_name='number', lookup_expr='exact', conjoined=True) # AND number_BaseCSVFilterNumber = BaseCSVFilterNumber(field_name='number', lookup_expr='in') number_BaseInFilterNumber = BaseInFilterNumber(field_name='number', lookup_expr='in') number_BaseRangeFilterNumber = BaseRangeFilterNumber(field_name='number', lookup_expr='range') is_true_BooleanFilter = BooleanFilter(field_name='is_true', lookup_expr='exact') text_CharFilter = CharFilter(field_name='text', lookup_expr='exact') number_ChoiceFilter = ChoiceFilter(field_name='number', lookup_expr='exact', choices=NUMBER_CHOICES) date_DateFilter = DateFilter(field_name='date', lookup_expr='exact') date_DateFromToRangeFilter = DateFromToRangeFilter(field_name='date', lookup_expr='range') date_DateRangeFilter = DateRangeFilter(field_name='date', lookup_expr='exact') date_time_DateTimeFilter = DateTimeFilter(field_name='date_time', lookup_expr='exact') date_time_DateTimeFromToRangeFilter = DateTimeFromToRangeFilter(field_name='date_time', lookup_expr='range') duration_DurationFilter = DurationFilter(field_name='duration', lookup_expr='exact') iso_date_time_IsoDateTimeFilter = IsoDateTimeFilter(field_name='iso_date_time', lookup_expr='lt') iso_date_time_IsoDateTimeFromToRangeFilter = IsoDateTimeFromToRangeFilter(field_name='iso_date_time', lookup_expr='range') number_MultipleChoiceFilter_OR = MultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=False, choices=NUMBER_CHOICES) number_MultipleChoiceFilter_AND = MultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=True, choices=NUMBER_CHOICES) number_NumberFilter = NumberFilter(field_name='number', lookup_expr='exact') number_OrderingFilter = OrderingFilter(fields=('number', 'number')) number_RangeFilter = RangeFilter(field_name='number', lookup_expr='range') time_TimeFilter = TimeFilter(field_name='time', lookup_expr='exact') time_TimeRangeFilter = TimeRangeFilter(field_name='time', lookup_expr='range') number_TypedChoiceFilter = TypedChoiceFilter(field_name='number', lookup_expr='exact', choices=NUMBER_CHOICES) text_TypedMultipleChoiceFilter_OR = TypedMultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=False, choices=NUMBER_CHOICES) text_TypedMultipleChoiceFilter_AND = TypedMultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=True, choices=NUMBER_CHOICES) uuid_UUIDFilter = UUIDFilter(field_name='uuid', lookup_expr='exact') number_LookupChoiceFilter = LookupChoiceFilter(field_name='number') class Meta: model = BenchmarkModel exclude = ['number', 'text', 'is_true', 'date', 'date_time', 'duration']
class PropertyAllValuesMultipleFilterSet(PropertyFilterSet): number = AllValuesMultipleFilter(field_name='number', lookup_expr=lookup_xpr, conjoined=conjoined) prop_number = PropertyAllValuesMultipleFilter(field_name='prop_number', lookup_expr=lookup_xpr, conjoined=conjoined) class Meta: model = AllValuesMultipleFilterModel fields = ['prop_number']
class OrderFilter(FilterSet): manager = AllValuesMultipleFilter(field_name='manager') class Meta: model = Order fields = [ 'manager', ]
class LessonFilter(FilterSet): day = AllValuesFilter(field_name='day') group = AllValuesFilter(field_name='group') week = AllValuesMultipleFilter(field_name='week') class Meta: model = Lesson fields = ( 'day', 'group', 'week', )
class SearchFilter(FilterSet): search = CharFilter( label='Search', method='sea', ) category = AllValuesMultipleFilter(field_name='category__name', ) price = RangeFilter(field_name='price', ) def sea(self, queryset, name, value): if value and len(value) > 2: return Items.objects.search(value) else: return Items.objects.none() class Meta: model = Items fields = ['search', 'category', 'price']
class UserIDFilter(FilterSet): votes = RangeFilter( widget=CustomRangeWidget(attrs={ 'type': 'number', 'step': 1 }, from_attrs={'placeholder': 'Votes from'}, to_attrs={'placeholder': 'Votes to'})) views = RangeFilter( widget=CustomRangeWidget(attrs={ 'type': 'number', 'step': 1 }, from_attrs={'placeholder': 'Views from'}, to_attrs={'placeholder': 'Views to'})) category = AllValuesMultipleFilter() shadowhidden = AllValuesFilter(empty_label='Shadowhidden') class Meta: model = Sponsortime fields = FIELDS exclude = ['username', 'user']
class AllValuesMultipleFilterSet(FilterSet): number = AllValuesMultipleFilter(field_name='number', lookup_expr=lookup_xpr, conjoined=conjoined) class Meta: model = AllValuesMultipleFilterModel fields = ['number']