Django REST Framework - Serializing optional fields
问题 I have an object that has optional fields. I have defined my serializer this way: class ProductSerializer(serializers.Serializer): code = serializers.Field(source="Code") classification = serializers.CharField(source="Classification", required=False) I thought required=False would do the job of bypassing the field if it doesn't exist. However, it is mentioned in the documentation that this affects deserialization rather than serialization. I'm getting the following error: 'Product' object has