Django REST Framework serializer field required=false

后端 未结 6 533
无人共我
无人共我 2020-11-30 05:30

from the documentation:

read_only Set this to True to ensure that the field is used when serializing a representation, but is not used when updating

6条回答
  •  鱼传尺愫
    2020-11-30 06:08

    Late Entry to this thread. This issue was fixed in django-rest-framework 2.3.13. Here is the link of the PR.

    You use it like this in your case:

        class Meta:
            model = models.FavoriteList
            optional_fields = ['owner', ]
    

提交回复
热议问题