本文整理汇总了Python中django_filters.NumberFilter方法的典型用法代码示例。如果您正苦于以下问题:Python django_filters.NumberFilter方法的具体用法?Python django_filters.NumberFilter怎么用?Python django_filters.NumberFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django_filters
的用法示例。
在下文中一共展示了django_filters.NumberFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_filter
# 需要导入模块: import django_filters [as 别名]
# 或者: from django_filters import NumberFilter [as 别名]
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
示例2: test_filterset_descriptions
# 需要导入模块: import django_filters [as 别名]
# 或者: from django_filters import NumberFilter [as 别名]
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"