使用divmod()出现错误
运行程序 total_page_count, div = divmod(total_count, page_size),出现unsupported operand type(s) for divmod(): 'method' and 'int' 错误,请帮我一下,谢谢了。
谢谢楼主,我也知道数据类型错误,但不知道错在哪里,求帮我看一下。
class Pagination(object):
def __init__(self,request,queryset,page_param="page",page_size=10,plus=5):
page=request.GET.get(page_param,'1')
if page.isdecimal():
page=int(page)
else:
page=1
self.page=page
self.page_size=page_size
self.start = (page - 1) * page_size
self.end = page * page_size
self.page_queryset=queryset[self.start:self.end]
total_count=queryset.count
total_page_count, div = divmod(total_count, page_size)
if div:
total_page_count += 1
self.total_page_count=total_page_count
self.plus=plus