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

18 lines
631 B
Python
Raw Normal View History

2022-01-15 17:40:16 +01:00
from rest_framework import generics
2022-01-03 00:09:16 +01:00
from rest_framework.response import Response
2022-01-16 16:06:58 +01:00
from .fuzzy_logic import get_fuzzy_response
2022-01-15 17:40:16 +01:00
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)
2022-01-16 16:06:58 +01:00
response = get_fuzzy_response(values)
print(response)
2022-01-15 17:40:16 +01:00
queryset = self.get_queryset()
serializer = CarSerializer(queryset, many=True)
return Response(serializer.data)