Python django_filters.NumberFilter() Examples
The following are 2
code examples of django_filters.NumberFilter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django_filters
, or try the search function
.
Example #1
Source File: renderers_filters.py From product-definition-center with MIT License | 6 votes |
def _get_filter(filter_name, filter): filter_type = _get_filter_option(filter, 'doc_format') if not filter_type: if isinstance(filter, NumberFilter): filter_type = 'int' else: filter_type = 'string' lookup_type = LOOKUP_TYPES.get(filter.lookup_expr) if lookup_type: lookup_type = ', %s' % lookup_type result = ' * `%s` (%s%s)' % (filter_name, filter_type, lookup_type or '') help_text = _get_filter_option(filter, 'help_text') if help_text: result += ' ' + help_text return result
Example #2
Source File: test_fields.py From graphene-django with MIT License | 5 votes |
def test_filterset_descriptions(): class ArticleIdFilter(django_filters.FilterSet): class Meta: model = Article fields = ["id"] max_time = django_filters.NumberFilter( method="filter_max_time", label="The maximum time" ) field = DjangoFilterConnectionField(ArticleNode, filterset_class=ArticleIdFilter) max_time = field.args["max_time"] assert isinstance(max_time, Argument) assert max_time.type == Float assert max_time.description == "The maximum time"