删除嵌套对象

时间:2016-10-07 22:15:44

标签: python django django-rest-framework

如果给定以下序列化程序结构,如何删除特定翻译:

from rest_framework import serializers    
from .models import Category, Translation


class CategoryTranslationSerializer(serializers.ModelSerializer):
    class Meta:
        model = Translation
        fields = ('name', 'title', 'language')


class CategorySerializer(serializers.ModelSerializer):
    translation_set = CategoryTranslationSerializer(many=True)

    class Meta:
        model = Category
        fields = ('id', 'order', 'parent', 'translation_set')

0 个答案:

没有答案