當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。