1 2 3 4 5 6 7 8 9 10 11 12
| from rest_framework.decorators import action
class SnippetViewSet(viewsets.ModelViewSet): ...
@action(detail=False, methods=['GET'], name='Get Highlight') def highlight(self, request, *args, **kwargs): queryset = models.Highlight.objects.all()
serializer = self.get_serializer(queryset, many=True) return Response(serializer.data)
|