[英]ModelSerializer doesn't respect the required attribute on a field
If I have: 如果我有:
class Example(serializers.ModelSerializer):
time = DateTimeRangeField(required=False)
it will fail with an error: 它将失败并显示错误:
{'time': ['This field is required.']}
However if this was serializers.Serializer it respects the required attribute on the field. 但是,如果这是serializers.Serializer,则它遵循字段上的必需属性。 Has anybody else come across this?
还有其他人遇到吗? Any ideas on how to make a field not required?
是否有关于如何创建字段的任何想法?
DateTimeRangeField
不是 Django REST框架字段,因此就像您根本没有提供任何字段一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.