def post(self, request, *args, **kwargs): serializer = serializers.FilterSerializer(data=request.data) if serializer.is_valid(): filtering_feed = serializer.save() bonuses = models.Bonus.filtering(filtering_feed) serialized_bonuses = serializers.BonusSerializer(bonuses, many=True) return Response(serialized_bonuses.data) return Response(serializer.errors)
def post(self, request, *args, **kwargs): serializer = serializers.SearchSerializer(data=request.data) if serializer.is_valid(): search_query = serializer.validated_data.get('search') bonuses = models.Bonus.get_searched_bonuses(search_query) serialized_bonuses = serializers.BonusSerializer(bonuses, many=True) return Response(serialized_bonuses.data) return Response(serializer.errors)
def get(self, request, *args, **kwars): queryset = models.Bonus.objects.all() serializer = serializers.BonusSerializer(queryset, many=True) return Response(serializer.data)