當前位置: 首頁>>代碼示例>>Python>>正文


Python django_filters.NumberFilter方法代碼示例

本文整理匯總了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 
開發者ID:product-definition-center,項目名稱:product-definition-center,代碼行數:20,代碼來源:renderers_filters.py

示例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" 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:17,代碼來源:test_fields.py


注:本文中的django_filters.NumberFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。