Introduction to Pagination
In this video, we are going to learn about pagination in django.
Let us imagine that you have thousands of data rows in the database table. When you create a list api for that database table, then you need to have some kind of mechanism to prevent querying all the data rows from the table. Because technically, if you return all the thousands of rows stored in your table, then the api response time will be slow and api response body will be too large.
In order to handle this type of schenario, django provides us a powerful feature called pagination.
Pagination is the process of dividing a large set of data into smaller, manageable chunks or pages. It allows you to display only a limited number of records on a page, so that it becomes easy for users to navigate through the data.
Example
Lets take an example, suppose you have 1000 vaccination centers stored in the database and you have to show vaccination centers to the user.
Now, if you show all the 1000 vacciation centers, it becomes difficult for user to naviagte through the data.
But, if I order all the 1000 vaccination centers by their name from A to Z and show first 10 vaccination centers on first page and next 10 vaccination centers on second page and so on, then it becomes easy for users to naviate through the data.
This process of ordering the data and then showing small chunk of data to the users is called pagination.
Now, I hope you have understood the basic concepts of pagination. In the next couple of videos, we will learn how to paginate the list view in django.