当前位置: 首页>>代码示例>>Python>>正文


Python urls.remove_query_param方法代码示例

本文整理汇总了Python中rest_framework.utils.urls.remove_query_param方法的典型用法代码示例。如果您正苦于以下问题:Python urls.remove_query_param方法的具体用法?Python urls.remove_query_param怎么用?Python urls.remove_query_param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rest_framework.utils.urls的用法示例。


在下文中一共展示了urls.remove_query_param方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_previous_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_previous_link(request):
    """ Generate URL of previous page in pagination. """
    limit = int(request.query_params.get('limit', api_settings.PAGE_SIZE))
    offset = int(request.query_params.get('offset', 0))

    if offset <= 0:
        return None

    url = request.build_absolute_uri()
    url = replace_query_param(url, 'limit', limit)

    if offset - limit <= 0:
        return remove_query_param(url, 'offset')

    offset = offset - limit
    return replace_query_param(url, 'offset', offset) 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:18,代码来源:util.py

示例2: get_html_context

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_html_context(self):
        base_url = self.request.build_absolute_uri()

        def page_number_to_url(page_number):
            if page_number == 1:
                return remove_query_param(base_url, self.page_query_param)
            else:
                return replace_query_param(base_url, self.page_query_param, page_number)

        current = self.page.number
        final = self.page.paginator.num_pages
        page_numbers = _get_displayed_page_numbers(current, final)
        page_links = _get_page_links(page_numbers, current, page_number_to_url)

        return {
            'previous_url': self.get_previous_link(),
            'next_url': self.get_next_link(),
            'page_links': page_links
        } 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:21,代码来源:pagination.py

示例3: get_last_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_last_link(self):
        if self.count == 0:
            return None

        url = self.request.build_absolute_uri()
        url = replace_query_param(url, self.limit_query_param, self.limit)

        offset = (self.count // self.limit) * self.limit

        if offset <= 0:
            return remove_query_param(url, self.offset_query_param)

        return replace_query_param(url, self.offset_query_param, offset) 
开发者ID:django-json-api,项目名称:django-rest-framework-json-api,代码行数:15,代码来源:pagination.py

示例4: get_first_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_first_link(self):
        if self.count == 0:
            return None

        url = self.request.build_absolute_uri()
        return remove_query_param(url, self.offset_query_param) 
开发者ID:django-json-api,项目名称:django-rest-framework-json-api,代码行数:8,代码来源:pagination.py

示例5: get_previous_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_previous_link(self):
        if self.offset <= 0:
            return None

        url = self.request.get_full_path()
        url = replace_query_param(url, self.limit_query_param, self.limit)

        if self.offset - self.limit <= 0:
            return remove_query_param(url, self.offset_query_param)

        offset = self.offset - self.limit
        return replace_query_param(url, self.offset_query_param, offset) 
开发者ID:ansible-community,项目名称:ara,代码行数:14,代码来源:pagination.py

示例6: get_first_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_first_link(self):
        if self.offset <= 0:
            return None
        url = self.request.get_full_path()
        return remove_query_param(url, self.offset_query_param) 
开发者ID:ansible-community,项目名称:ara,代码行数:7,代码来源:pagination.py

示例7: get_previous_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_previous_link(self):
        if self.offset <= 0:
            return None
        url = self.request.build_absolute_uri()
        if self.offset - self.limit <= 0:
            return remove_query_param(url, self.start_query_param)
        offset = self.offset - self.limit
        return replace_query_param(
            url, self.start_query_param, self.queryset[offset].address
        ) 
开发者ID:openwisp,项目名称:openwisp-ipam,代码行数:12,代码来源:views.py

示例8: get_first_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_first_link(self, display_page_query_param=True):
        url = self.request.build_absolute_uri()
        if display_page_query_param:
            page_number = self.page.paginator.validate_number(1)
            return replace_query_param(url, self.page_query_param, page_number)
        else:
            return remove_query_param(url, self.page_query_param) 
开发者ID:silverapp,项目名称:silver,代码行数:9,代码来源:pagination.py

示例9: get_previous_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_previous_link(self):
        if not self.page.has_previous():
            return None
        url = self.request.build_absolute_uri()
        page_number = self.page.previous_page_number()
        if page_number == 1:
            return remove_query_param(url, self.page_query_param)
        return replace_query_param(url, self.page_query_param, page_number) 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:10,代码来源:pagination.py

示例10: get_previous_link

# 需要导入模块: from rest_framework.utils import urls [as 别名]
# 或者: from rest_framework.utils.urls import remove_query_param [as 别名]
def get_previous_link(self):
        if self.offset <= 0:
            return None
        url = self.request.build_absolute_uri()
        if self.offset - self.limit <= 0:
            return remove_query_param(url, self.start_query_param)
        offset = self.offset - self.limit
        return replace_query_param(url, self.start_query_param, self.queryset[offset].address) 
开发者ID:openwisp,项目名称:django-ipam,代码行数:10,代码来源:generics.py


注:本文中的rest_framework.utils.urls.remove_query_param方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。