diff --git a/suitablephones/views.py b/suitablephones/views.py index 062e978..69d3c30 100644 --- a/suitablephones/views.py +++ b/suitablephones/views.py @@ -1,5 +1,16 @@ from django.shortcuts import render from django.http import HttpResponse +from django.views.generic.list import ListView +from suitablephones.models import Device, Camera -def suitablephones(request): - return HttpResponse("These are suitable phones") + +class SuitablePhones(ListView): + model = Device + + def get_request_camera(self): + return self.request.GET.get("camera") + + + def get_queryset(self): + camera = self.get_request_camera() + return self.model.objects.filter(camera=camera)