Systemy-rozmyte-sql/backend/cars/views.py
2022-01-15 17:40:16 +01:00

15 lines
517 B
Python

from rest_framework import generics
from rest_framework.response import 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)
queryset = self.get_queryset()
serializer = CarSerializer(queryset, many=True)
return Response(serializer.data)