Django pagination error, int has no len -
@csrf_exempt def board_searched(request): searchstr = request.get['searchstr'] pageforview = request.get['pageforview'] contact_list = board.objects.filter(title__contains=searchstr).count() paginator = paginator(contact_list, 10) # show 25 contacts per page contacts = paginator.page(1) return render(request, 'board/board_searched.html', {'contacts': contacts})
this views.py code, processing search in board. , give link http://127.0.0.1:8000/board/search/result/?searchstr=asd&pageforview=1
in case, occurred object of type 'int' has no len()
and, occurred @
contacts = paginator.page(1)
what problem..?
you need remove count()
here:
contact_list = board.objects.filter(title__contains=searchstr).count()
it should be:
contact_list = board.objects.filter(title__contains=searchstr)
you have provide queryset, , amount want returned. before, not passing queryset, number, invalid.
Comments
Post a Comment