Объект типа 'function' не имеет len()

В настоящее время я работаю над пагинацией. Моя главная проблема в том, что оператор try не работает правильно, как я думал

Это Util.py, который я использовал для получения диапазона пагинации и объектов

.

Projects - это мой объект, который содержит элементы, которые мне нужно отобразить, а result - это количество проектов, которые нужно отобразить

def PagePaginator(request,projects,result):
page=request.GET.get('page')
paginator=Paginator(projects,result)

try:
    projects=paginator.page(page)
except PageNotAnInteger:
    page=1
    projects=paginator.page(page)    
except EmptyPage:
    page=paginator.num_pages
    projects=paginator.page(page)
    
leftindex=int(page)-1
if leftindex < 1:
    leftindex=1
rightindex=int(page)+2
if rightindex > paginator.num_pages:
    rightindex=paginator.num_pages
    
custom_range=range(leftindex,rightindex)

return custom_range,projects

Полный вид

.

The first SearchProfileUtils, search and return the specific profile/data that I gave request to search in the search bar, and the item which I request to find, called as search_item. And ProfilePagePaginator is the function which iam having the error and it's mentioned above

@login_required(login_url='login')
`def profiles(request):
    profile,search_item=SearchProfileUtils(request)
    custom_range,projects=ProfilePagePaginator(request,profiles,1)
    context={
        "search_item":search_item,
        'profiles':profile,
        # 'custom_range':custom_range
    }
    return render(request,'users/profiles.html',context)`

Здесь часть html, где я получаю значение страницы

<a href="?page={{page}}" class='btn page-link btn--sub'>{{page}}</a>

Я получаю ошибку в операторе try.

Вернуться на верх