class SectionSerializer(serializers.ModelSerializer):
images = ImageSerializer(many = True, read_only = True)
images2 = Image2Serializer(many = True, read_only = True)
class Meta:
model = Sections
fields = ('id', 'name', 'audio1', 'audio2', 'images', 'images2')
[
{
"id": 1,
"name": "Lake1",
"audio1": "qwe",
"audio2": "qwe",
"images": [
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
"images2": [
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
},
{
"id": 2,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
}
]
}
]
var obj = {
"id": 1,
"name": "Lake1",
"audio1": "qwe",
"audio2": "qwe",
"images": [
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
}],
"images2":
[
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
},
{
"id": 2,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
}
]
}
obj.images.images2 = obj.images2;
delete obj.images2;
{
"id": 1,
"name": "Lake1",
"audio1": "qwe",
"audio2": "qwe",
"images": [
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png",
"images2":
[
{
"id": 1,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
},
{
"id": 2,
"file_name": "/images/66acc105-1c06-45aa-a3b8-5_S3USvg3.png"
}
]
}]
}