在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.
不明白是什么意思,求解释下
4 回答4.4k 阅读✓ 已解决
4 回答3.8k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
1 回答4.5k 阅读✓ 已解决
1 回答3.8k 阅读✓ 已解决
1 回答2.8k 阅读✓ 已解决
就是说你在Model里定义的类似下面这样的方法也可以写进
fields
里面:有一个要求就是这些
property
或者method
不能有除self
以外其他的参数