本文整理匯總了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"