在我的序列化程序.py,我创建了一个UserListSerializer:
class UserListSerializer(ModelSerializer):
class Meta:
model = User
fields = '__all__'
exclude = [
'password',
]
我想实现排除字段功能,但失败了。在
AssertionError at /api/users/list/
Cannot set both 'fields' and 'exclude' options on serializer UserListSerializer.
有没有可能因为字段太多而实现这个功能?在
不能在序列化程序的元类中同时使用字段和排除
不如试试这个
相关问题 更多 >
编程相关推荐