Skip to content

Commit ceeffe7

Browse files
committed
pagination for direct/project messages
1 parent 245648d commit ceeffe7

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

chats/pagination.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from rest_framework import pagination
2+
3+
4+
class MessageListPagination(pagination.LimitOffsetPagination):
5+
default_limit = 15
6+
limit_query_param = "next"
7+
offset_query_param = "previous"

chats/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from rest_framework.response import Response
77

88
from chats.models import ProjectChat, DirectChat
9+
from chats.pagination import MessageListPagination
910
from chats.serializers import (
1011
DirectChatListSerializer,
1112
DirectChatMessageListSerializer,
@@ -94,6 +95,7 @@ def get(self, request, *args, **kwargs) -> Response:
9495
class DirectChatMessageList(ListCreateAPIView):
9596
serializer_class = DirectChatMessageListSerializer
9697
permission_classes = [IsAuthenticated]
98+
pagination_class = MessageListPagination
9799

98100
def get_queryset(self):
99101
return (
@@ -106,6 +108,7 @@ def get_queryset(self):
106108
class ProjectChatMessageList(ListCreateAPIView):
107109
serializer_class = ProjectChatMessageListSerializer
108110
permission_classes = [IsAuthenticated]
111+
pagination_class = MessageListPagination
109112

110113
def get_queryset(self):
111114
return (

0 commit comments

Comments
 (0)