AttributeError at /ServerAutoReport/
1
Got AttributeError when attempting to get a value for field `device` on serializer `AutoReportSerializer`.
2
The serializer field might be named incorrectly and not match any attribute or key on the `Server` instance.
3
Original exception text was: 'Server' object has no attribute 'device'.

解决方案

1
device           = serializers.JSONField(required=True, label="网卡", help_text="网卡", write_only=True)

这个字段在server_obj不存在, 只是用来反序列化, 所以这里必须加上该字段属性write_only=True

序列化器
正序和反序列化字段不统一l
required=False 只序列化不走校验
read_only=True 只序列化用
write_only=True 只反序列化用
重写create方法