本文整理汇总了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)
示例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
}
示例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)
示例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)
示例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)
示例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)
示例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
)
示例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)
示例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)
示例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)