First, make sure you use the SessionAuthentication in Django. Put this in your settings.py
# Django rest framework
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication'| from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | |
| # First we create a little helper function, becase we will potentially have many PaginatedTypes | |
| # and we will potentially want to turn many querysets into paginated results: | |
| def get_paginator(qs, page_size, page, paginated_type, **kwargs): | |
| p = Paginator(qs, page_size) | |
| try: | |
| page_obj = p.page(page) | |
| except PageNotAnInteger: |