보내주려는 데이터가 있다면 이를 쪼개서 제공한다.
Paginator(self, object_list, per_page, ...)
object_list --> list/tuple/Querysetper_page --> 페이지 당 표시하려는 객체 수객체 수 를 파악하고자 할 때 count() -> len() 메서드 순으로 객체를 계산한다.
class Paginator:
def __init__(self, object_list, per_page, orphans=0,
allow_empty_first_page=True):
self.object_list = object_list
self._check_object_list_is_ordered()
self.per_page = int(per_page)
self.orphans = int(orphans)
self.allow_empty_first_page = allow_empty_first_page
...
pagination 기능이 있어 paginate_by 변수에 한 페이지에 표시할 수 를 기입만 해주며 된다.
response headers 에 Content-Range 와 Link 를 제공하는 기능generic views 와 viewsets 을 사용 할 경우 Pagination 을 추가 할 필요 없이 사용할 수 있다.