short queryset
This commit is contained in:
parent
5502be73bb
commit
2519fe4cca
2 changed files with 4 additions and 4 deletions
|
@ -31,4 +31,4 @@ class DeviceSerializer(serializers.ModelSerializer):
|
|||
class DeviceSerializerShort(DeviceSerializer):
|
||||
class Meta:
|
||||
model = Device
|
||||
include = ["codename", "vendor", "name", "release", "maintainers", "cameras", "battery", "screen"]
|
||||
fields = ["codename", "vendor", "name", "versions", "maintainers", "cameras", "screen"]
|
|
@ -5,13 +5,13 @@ from rest_framework import viewsets
|
|||
|
||||
from suitablephones.models import Bluetooth, Camera, Device
|
||||
from suitablephones.serializers import (BluetoothSerializer, CameraSerializer,
|
||||
DeviceSerializer)
|
||||
DeviceSerializer, DeviceSerializerShort)
|
||||
|
||||
|
||||
# ViewSets define the view behavior.
|
||||
class DeviceViewSet(viewsets.ModelViewSet):
|
||||
queryset = Device.objects.all()
|
||||
serializer_class = DeviceSerializer
|
||||
serializer_class = DeviceSerializerShort
|
||||
|
||||
#http://url/api/devices?megapixel=3
|
||||
def get_queryset(self):
|
||||
|
@ -29,7 +29,7 @@ class DeviceViewSet(viewsets.ModelViewSet):
|
|||
if version:
|
||||
self.queryset = self.queryset.filter(versions__icontains=version)
|
||||
if size_in:
|
||||
self.queryset = self.queryset.filter(screen__size_in__gt=Decimal(size_in))
|
||||
self.queryset = self.queryset.filter(screen__size_in__lt=Decimal(size_in))
|
||||
if resolution:
|
||||
self.queryset = self.queryset.filter(screen__resolution__icontains=resolution)
|
||||
if screen_type:
|
||||
|
|
Loading…
Reference in a new issue