Wednesday, September 25, 2019

RE: where is the error in pagination?

Try this one :

paginator = Paginator(queryset_list,8# Show 25 contacts per page
page_request_var = "page"
page = request.GET.get(page_request_var)
try:
    queryset = paginator.page(page)
except PageNotAnInteger:
   
# If page is not an integer, deliver first page.
   
queryset = paginator.page(1)
except EmptyPage:
   
# If page is out of range (e.g. 9999), deliver last page of results.
   
queryset = paginator.page(paginator.num_pages)

 

 

Sent from Mail for Windows 10

 

From: leb dev
Sent: Wednesday, September 25, 2019 2:32 PM
To: Django users
Subject: where is the error in pagination?

 

i have a django project  and it includes pagination i do not know where is the error in my code but once i tired to go to the next or previous page it crash and display the below error :

 

> can only concatenate str(not ""NoneType) to str

 

            query=request.GET.get("search")

            paginator = Paginator(queryset_list, 5) 

            page_request_var = "page"

            print("page_request_var===>",page_request_var)

            page = request.GET.get(page_request_var)

            print("page===>",page)

            queryset = paginator.get_page(page)

            print("queryset===>",queryset)

 

When i print **page** it display None

 

 

 In the browser it suppose to display **page=2&search=sam**

but instead 

it display **/?=2&20search%20=%20sam**

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82e3fe0e-e872-4a49-b869-2b67001e3270%40googlegroups.com.

 

No comments:

Post a Comment