Systemy-rozmyte-sql/backend/cars/views.py

18 lines
641 B
Python

from rest_framework import generics
from rest_framework.response import Response
from .fuzzy_logic import get_fuzzy_response
from .models import Car
from .serializers import CarSerializer
from .utils import map_query_params
class CarList(generics.ListAPIView):
queryset = Car.objects.all()
serializer_class = CarSerializer
def list(self, request):
values = map_query_params(request.query_params)
response = get_fuzzy_response(values, queryset)
print(response)
queryset = self.get_queryset()
serializer = CarSerializer(queryset, many=True)
return Response(serializer.data)