在rest_framework官方文档ModelSerializer部分看到这样一句话:
Alternatively names in the fields options can map to properties or methods which take no arguments that exist on the model class.
不明白是什么意思,求解释下
在rest_framework官方文档ModelSerializer部分看到这样一句话:
Alternatively names in the fields options can map to properties or methods which take no arguments that exist on the model class.
不明白是什么意思,求解释下
2 回答4.1k 阅读✓ 已解决
2 回答789 阅读✓ 已解决
1 回答4.1k 阅读✓ 已解决
2 回答2.1k 阅读✓ 已解决
3 回答764 阅读✓ 已解决
4 回答2.5k 阅读
3 回答788 阅读✓ 已解决
就是说你在Model里定义的类似下面这样的方法也可以写进
fields
里面:有一个要求就是这些
property
或者method
不能有除self
以外其他的参数