34 lines
No EOL
950 B
Python
34 lines
No EOL
950 B
Python
from rest_framework import serializers
|
|
|
|
from suitablephones.models import Bluetooth, Camera, Device, Screen
|
|
|
|
|
|
class CameraSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Camera
|
|
exclude = ["id"]
|
|
|
|
|
|
class BluetoothSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Bluetooth
|
|
exclude = ["id"]
|
|
|
|
class ScreenSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Screen
|
|
exclude = ["id"]
|
|
|
|
class DeviceSerializer(serializers.ModelSerializer):
|
|
bluetooth = BluetoothSerializer(many=False, read_only=True)
|
|
cameras = CameraSerializer(many=True, read_only=True)
|
|
screen = ScreenSerializer(many=True, read_only=True)
|
|
|
|
class Meta:
|
|
model = Device
|
|
exclude = ["id"]
|
|
|
|
class DeviceSerializerShort(DeviceSerializer):
|
|
class Meta:
|
|
model = Device
|
|
fields = ["codename", "vendor", "name", "versions", "maintainers", "cameras", "screen"] |