我们如何使用请求对象在serializer.py中动态追加额外的字段

时间:2017-03-27 02:10:47

标签: django django-rest-framework

http://127.0.0.1:8000/?words=anger

我想动态地向场序列化器添加'anger'。

from .models import Synonym
from rest_framework import serializers

class SynonymSerializer(serializers.ModelSerializer):
    class Meta:        
        model = Synonym
        fields = ('word',)

0 个答案:

没有答案