diff --git a/notifications/serializers.py b/notifications/serializers.py index 4bbd23c..a5c8514 100644 --- a/notifications/serializers.py +++ b/notifications/serializers.py @@ -7,7 +7,7 @@ class NotificationSerializer(serializers.ModelSerializer): class Meta: model = Notification - fields = ['id', 'content', 'note_type', 'is_read', 'meta'] + fields = ['id', 'content', 'note_type', 'is_read', 'created_at', 'meta'] def get_meta(self, obj): diff --git a/notifications/views.py b/notifications/views.py index aae2dfb..6e046be 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -20,12 +20,11 @@ class NotificationReadViewSet(ReadOnlyModelViewSet): # 30일 이전 알림만 가져옴 def get_queryset(self): qs = UserToNotificationService.get_all_notification(self.request.user) - print(qs) - return qs.select_related( + return qs.order_by('-created_at').select_related( 'project_invitation__project', 'project_invitation__from_user', ) - + def retrieve(self, request, *args, **kwargs): instance = self.get_object() instance.is_read = True