本文整理匯總了Python中pure_pagination.PageNotAnInteger方法的典型用法代碼示例。如果您正苦於以下問題:Python pure_pagination.PageNotAnInteger方法的具體用法?Python pure_pagination.PageNotAnInteger怎麽用?Python pure_pagination.PageNotAnInteger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pure_pagination
的用法示例。
在下文中一共展示了pure_pagination.PageNotAnInteger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_context_data
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get_context_data(self, **kwargs):
try:
page = self.request.GET.get('page', 1)
except PageNotAnInteger as e:
page = 1
p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
list = p.page(page)
context = {
"tasks_active": "active",
"tools_results_active": "active",
"tools_results_list": list,
'date_from': (datetime.datetime.now() + datetime.timedelta(days=-7)).strftime('%Y-%m-%d'),
'date_to': (datetime.datetime.now() + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
}
kwargs.update(context)
return super().get_context_data(**kwargs)
示例2: get_context_data
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get_context_data(self, **kwargs):
try:
page = self.request.GET.get('page', 1)
except PageNotAnInteger as e:
page = 1
p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
list = p.page(page)
context = {
"crontab_active": "active",
"crontab_periodictasks_result_active": "active",
"periodictassks_results_list":list,
'date_from': (datetime.datetime.now() + datetime.timedelta(days=-7)).strftime('%Y-%m-%d'),
'date_to': (datetime.datetime.now() + datetime.timedelta(days=+1)).strftime('%Y-%m-%d')
}
kwargs.update(context)
return super().get_context_data(**kwargs)
示例3: get_context_data
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get_context_data(self, **kwargs):
"""
獲取係統用戶,再獲取用戶的組 根據組 去判斷 資產所屬的資產項目 是否 有 讀取的權限
:return: 返回有 讀取權限的資產
"""
try:
page = self.request.GET.get('page', 1)
except PageNotAnInteger as e:
page = 1
p = Paginator(self.queryset, getattr(settings,'DISPLAY_PER_PAGE'), request=self.request)
asset_list = p.page(page)
# 左側導航站展開 "asset_active": "active",
context = {
"asset_active": "active",
"asset_list_active": "active",
"asset_list":asset_list,
"web_ssh": getattr(settings, 'web_ssh'),
"web_port": getattr(settings, 'web_port'),
}
kwargs.update(context)
return super().get_context_data(**kwargs)
示例4: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
all_message = UserMessage.objects.filter(user=request.user.id)
# 用戶進入個人中心消息頁麵,清空未讀消息記錄
all_unread_messages = UserMessage.objects.filter(
user=request.user.id, has_read=False)
for unread_message in all_unread_messages:
unread_message.has_read = True
unread_message.save()
# 對課程機構進行分頁
# 嘗試獲取前台get請求傳遞過來的page參數
# 如果是不合法的配置參數默認返回第一頁
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
# 這裏指從allorg中取五個出來,每頁顯示5個
p = Paginator(all_message, 4)
messages = p.page(page)
return render(request, "usercenter-message.html", {
"messages": messages,
})
示例5: Home
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def Home(request):
"""
首頁
:param request:
:return:
"""
recommend = Recommend.objects.filter(is_recommend=True)[:10]
qq = QQ.objects.all()
links = link.objects.all()
try:
page = request.GET.get('page', 1)
if page == '':
page = 1
except PageNotAnInteger:
page = request.GET.get('page')
# Provide Paginator with the request object for complete querystring generation
dynamicList = dynamic.objects.filter(is_delete=False)[:500]
dynamicPage = Paginator(dynamicList, 10, request=request).page(page)
banners = Banners.objects.first()
return render(request, 'pc/index.html', {'dynamicPage':dynamicPage})
示例6: ArticleList
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def ArticleList(request):
"""
文章list
:param request:
:return:
"""
seo_list = get_object_or_404(Seo, name='文章')
article = Article.objects.filter(is_show=True)
category = Category_Article.objects.all().order_by('order')
type = request.GET.get('type', '')
try:
page = request.GET.get('page', 1)
if type:
article =Article.objects.filter(category_id=type,is_show=True)
if page == '':
page = 1
except PageNotAnInteger:
page = 1
# Provide Paginator with the request object for complete querystring generation
p = Paginator(article,10,request=request)
people = p.page(page)
headlines = Headlines.objects.all()[:30]
banners = Banners.objects.first()
return render(request, 'pc/article.html', {'seo_list':seo_list,'article': people,'category':category,'Headlines':headlines,'banners':banners})
示例7: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request, item_id):
item = Product.objects.get(id=int(item_id))
all_review = item.get_review()
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
# 對評論進行分頁
p = Paginator(all_review, 5, request=request)
reviews = p.page(page)
return render(request, "product_item.html", {
"item": item,
"all_review": reviews,
})
示例8: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
all_courses = Course.objects.all().order_by("-add_time")
hot_courses = Course.objects.all().order_by("-click_nums")[:3]
# -----------------站內課程搜索-----------------------
search_keywords = request.GET.get('keywords', "")
if search_keywords:
# 在name字段進行操作,做like語句的操作。icontains中i代表不區分大小寫
# or操作使用Q
all_courses = all_courses.filter(Q(name__icontains=search_keywords) | Q(desc__icontains=search_keywords) |
Q(detail__icontains=search_keywords))
# ------課程排序-----------
sort = request.GET.get('sort', "")
if sort:
if sort == "students":
all_courses = all_courses.order_by("-students")
elif sort == "hot":
all_courses = all_courses.order_by("-click_nums")
# --------對課程進行分頁----------------
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
p = Paginator(all_courses, 6, request=request)
courses = p.page(page)
return render(request, 'course-list.html', {
"all_courses": courses,
"sort": sort,
"hot_courses": hot_courses
})
# ----------------課程詳情頁----------------------------
示例9: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
all_teachers = Teacher.objects.all()
# -----------------站內課程搜索-----------------------
search_keywords = request.GET.get('keywords', '')
if search_keywords:
# 在name字段進行操作,做like語句的操作。i代表不區分大小寫
# or操作使用Q
all_teachers = all_teachers.filter(Q(name__icontains=search_keywords) |
Q(work_company__icontains=search_keywords) |
Q(work_position__icontains=search_keywords)|
Q(points__icontains=search_keywords))
sort = request.GET.get('sort', "")
if sort:
if sort == "hot":
all_teachers = all_teachers.order_by("-click_nums")
# -------------講師排行--------------------------------
sorted_teacher = Teacher.objects.all().order_by("-click_nums")[:7]
# -----講師列表分頁-----------------------------------------
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
p = Paginator(all_teachers, 3, request=request)
teachers = p.page(page)
return render(request, "teachers-list.html", {
"all_teachers": teachers,
"sorted_teacher": sorted_teacher,
"sort": sort
})
# ---------------------講師詳情頁-----------------------------
示例10: html_export
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def html_export(request, username, id_string):
limit = request.REQUEST.get('limit', 100)
# get_instances_for site_form
cursor = get_instances_for_user_and_form(username, id_string)
paginator = Paginator(cursor, limit, request=request)
try:
page = paginator.page(request.REQUEST.get('page', 1))
except (EmptyPage, PageNotAnInteger):
try:
page = paginator.page(1)
except (EmptyPage, PageNotAnInteger):
page = None
context = {
'page': page,
'table': []
}
if page:
data = [("v1", page.object_list)]
export = build_export(request, username, id_string)
context['table'] = mark_safe("\n".join(export.to_html(data)))
context['title'] = id_string
return render(request, 'export/export_html.html', context)
示例11: get_context_data
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get_context_data(self, **kwargs):
try:
page = self.request.GET.get('page', 1)
except PageNotAnInteger as e:
page = 1
p = Paginator(self.queryset, getattr(settings, 'DISPLAY_PER_PAGE'), request=self.request)
ecs_list = p.page(page)
context = {
"ecs_list": ecs_list,
"filter_dict": self.filter_dict # 把查詢條件返回給前端
}
kwargs.update(context)
return super().get_context_data(**kwargs)
示例12: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
all_course = Course.objects.all()
# 熱門課程推薦
hot_courses = Course.objects.all().order_by("-students")[:3]
# 搜索功能
search_keywords = request.GET.get('keywords', '')
if search_keywords:
# 在name字段進行操作,做like語句的操作。i代表不區分大小寫
# or操作使用Q
all_course = all_course.filter(Q(name__icontains=search_keywords) | Q(
desc__icontains=search_keywords) | Q(detail__icontains=search_keywords))
# 對課程進行分頁
# 嘗試獲取前台get請求傳遞過來的page參數
# 如果是不合法的配置參數默認返回第一頁
# 進行排序
sort = request.GET.get('sort', "")
if sort:
if sort == "students":
all_course = all_course.order_by("-students")
elif sort == "hot":
all_course = all_course.order_by("-click_nums")
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
# 這裏指從all_org中取五個出來,每頁顯示5個
p = Paginator(all_course, 6, request=request)
courses = p.page(page)
return render(request, "course-list.html", {
"all_course": courses,
"sort": sort,
"hot_courses": hot_courses,
"search_keywords": search_keywords
})
示例13: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
all_teacher = Teacher.objects.all()
sort = request.GET.get("sort", "")
if sort:
if sort == "hot":
all_teacher = all_teacher.order_by("-click_nums")
# 搜索功能
search_keywords = request.GET.get('keywords', '')
if search_keywords:
# 在name字段進行操作,做like語句的操作。i代表不區分大小寫
# or操作使用Q
all_teacher = all_teacher.filter(Q(name__icontains=search_keywords) | Q(
work_company__icontains=search_keywords))
# 排行榜講師
rank_teacher = Teacher.objects.all().order_by("-fav_nums")[:5]
# 總共有多少老師使用count進行統計
teacher_nums = all_teacher.count()
# 對講師進行分頁
# 嘗試獲取前台get請求傳遞過來的page參數
# 如果是不合法的配置參數默認返回第一頁
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
# 這裏指從allorg中取五個出來,每頁顯示5個
p = Paginator(all_teacher, 4, request=request)
teachers = p.page(page)
return render(request, "teachers-list.html", {
"all_teacher": teachers,
"teacher_nums": teacher_nums,
"sort": sort,
"rank_teachers": rank_teacher,
"search_keywords": search_keywords,
})
示例14: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
message_board = MessageBoard.objects.order_by('-add_time')
# 留言用戶郵箱信息保密,將其中的部分字符轉換成 * 號
for message in message_board:
name, addr = message.email.split('@')
if len(name) > 5:
name = name[0:3] + '*'*len(name[3:])
else:
addr = '*'*len(addr)
message.email = name + '@' + addr
# 用戶留言分頁
old_message_page = request.session.get('message_board_page', 1)
try:
message_page = request.GET.get('message_page', 1)
request.session['message_board_page'] = message_page
except PageNotAnInteger:
message_page = 1
# 對數據庫中所取出的所有對象,進行分頁,中間的參數為每頁顯示的對象個數,設置為 6 個
paginator = Paginator(message_board, 10, request=request, page_type='message_page')
# 取出對應頁的數據
message_board_page = paginator.page(message_page)
if old_message_page != message_page:
message_focus = 'read'
else:
message_focus = 'add'
return render(request, 'message.html', {
'message': message_board_page,
"focus": "message",
"message_focus": message_focus
})
示例15: get
# 需要導入模塊: import pure_pagination [as 別名]
# 或者: from pure_pagination import PageNotAnInteger [as 別名]
def get(self, request):
"""排行榜的 get 方法"""
food_list = FoodArticle.objects.order_by("-like")
# 熱門食物--做過的人最多
popular_food = FoodArticle.objects.order_by("-fav")[:3]
# 無數據的情況
if food_list:
message = True
else:
message = False
# 獲取頁麵傳回的分頁數值,默認為 1(第一頁)
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
# 對數據庫中所取出的所有對象,進行分頁,中間的參數為每頁顯示的對象個數,設置為 6 個
paginator = Paginator(food_list, 12, request=request)
# 取出對應頁的數據
food_list_page = paginator.page(page)
return render(request, 'food/food_ranking.html', {
"food_list": food_list_page,
"popular_food": popular_food,
"message": message,
"focus": "article", # 選中狀態標誌
})