Compare commits

...

2 commits

Author SHA1 Message Date
d0c
f6a4745dfd fix serializer response 2023-02-17 14:50:26 +01:00
d0c
2cb87ebb90 str 2023-02-17 14:39:59 +01:00
2 changed files with 4 additions and 3 deletions

View file

@ -20,7 +20,7 @@ class Camera(models.Model):
info = models.CharField(max_length=100, null=True)
def __str__(self):
return f" {self.flash} - {str(self.megapixel)} - {self.info}"
return f"{self.flash} - {str(self.megapixel)} - {self.info}"
class Screen(models.Model):
size = models.CharField(max_length=500, null=True)
@ -31,7 +31,7 @@ class Screen(models.Model):
technology = models.CharField(max_length=100)
def __str__(self):
return f"{self.size_in} - {self.density} - {self.technology}"
return f"{str(self.size_in)} - {str(self.density)} - {str(self.technology)}"
class Device(models.Model):
#architecture = models.JSONField(default=dict)

View file

@ -1,6 +1,6 @@
from rest_framework import serializers
from suitablephones.models import Bluetooth, Camera, Device
from suitablephones.models import Bluetooth, Camera, Device, Screen
class CameraSerializer(serializers.ModelSerializer):
@ -22,6 +22,7 @@ class ScreenSerializer(serializers.ModelSerializer):
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