Questions tagged [django-pagination]

Django-pagination refers to the Django (a Python-based and open-source web framework) way of managing data split across several pages, with "Previous/Next" links. Use this tag for questions related to classes related to pagination in Django.

Django-pagination refers to the Django (a Python-based and open-source web framework) way of managing data split across several pages, with "Previous/Next" links. Use this tag for questions related to classes related to pagination in Django.

300 questions
1
vote
0 answers

PageNumberPagination in django via custom queryset

Scenario : I am using django rest framework and I want to create an API to list products using Pagination. Problem: I have a dictionary coming through a defined method (which shows products for a filtered category) and now I want to pass this…
1
vote
2 answers

Pagination in filtered queryset using Django Listview

I´m having a problem when using pagination in generic ListView, when trying to filter queryset. The filter works fine, but the thing is when trying to access a page that isn´t the first,an error appears: Invalid page (2): That page contains no…
1
vote
1 answer

Django pagination is not working properly when using POST method in Search form

I am trying to search an item in a form using POST method and I got the results. But when I use Django pagination, I got the results in the first page. When I click the next or 2 button in Django paginator I got an error like this. The view…
Abin Benny
  • 125
  • 2
  • 10
1
vote
1 answer

How to solve "object of type 'Course' has no len()" error that I am getting after using paginator in a view function?

This is my model. I have a many to one relationship. class Course(models.Model): course_name = models.CharField(max_length=100) class Coursegk(models.Model): question = models.CharField(max_length=1000) option_one =…
1
vote
1 answer

Sorting and paginating object at the same time in django; after paginating the sort gets reset

If I have applied the sorting to my wallpapers and after that if I try to paginate the sorting gets reset. like if I have sorted wallpapers according to pub date in ascending order and after pagination, it gets back to normal. view def…
1
vote
1 answer

django-sorting and django-pagination: middleware order

I am using django-pagination and django-sorting together for one of my views. Both these have custom middleware to sort and paginate. So is the order of middleware important in this case?
Konstant
  • 2,179
  • 16
  • 32
1
vote
2 answers

pagination in django rest framework not working

I have written CustomPagination from drf in a separate file in my project which is like this. class ProductPageNumberPagination(PageNumberPagination): page_size = 1 class CustomPagination(PageNumberPagination): def…
Reactoo
  • 916
  • 2
  • 12
  • 40
1
vote
3 answers

Paginating Django View with Foreign Key Data

I'm trying to build a simple Django gallery that allows photos to be added to an album. Everything thus far is working fine (upload photo, add to album, paginated all photos listing, photo details/display pages, etc), until I try to display the…
1
vote
1 answer

Combining ordering and pagination in Django

I am using rest_framework.pagination.LimitOffsetPagination in combination with Django's sort filter (with filter_backends = [OrderingFilter] and ordering_fields in my view). The problem is that Django appears to be applying the sort on the…
Marcel
  • 135
  • 7
1
vote
2 answers

Django Paginator shows post titles Not Page numbers, why?

i'm trying to use Django Paginator using ListView, but the paginator shows post title instead of page number: Page number replaced with post title how can i fix that? this is my code: in views.py: from django.shortcuts import render from…
1
vote
0 answers

Add Pagination in Django Rest Framework

I am trying to use PageNumberPagination in DRF anf for that I have changed the settings.py file like the following: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', …
Rahul Sharma
  • 2,187
  • 6
  • 31
  • 76
1
vote
1 answer

field_name = ordering[0].lstrip('-') throws IndexError: tuple index out of range in DRF rest_framework\pagination.py

I am getting error IndexError: tuple index out of range while using CursorPagination of DRF. my code- class CursorSetPagination(CursorPagination): page_size = 10 page_size_query_param = 'page_size' ordering = '-created_at' class…
1
vote
0 answers

Django + PostgreSQL: pagination extremely slow for millions of objects

I have around 6 million objects in my database. For these objects, I need to have a structure page, where the users would browse through the aforementioned 6 million objects as paginated content. My code for the pagination is a total duplicate of…
Edmond
  • 59
  • 2
  • 15
1
vote
1 answer

Failed lookup for key - implementing pagination with elided_page

I am attempting to implement pagination with elided_page based on this blog post. My goal is to have pagination with only a few pages being showed and increase as a new page is viewed as I will eventually have over a hundred pages. view def…
Wazy
  • 462
  • 4
  • 17
1
vote
3 answers

custom pagination not woking in apiview of Django rest

I have a custom pagination class in a separate file and until now I have been importing it in a ListAPIView, but this time I tried with APIView, but it didn't work. My pagination class: class CustomPagination(PageNumberPagination): def…