采用的是django_rest_framework框架。序列化则是通过serializer类来实现。所以在serializer中完成
class xxxTableSerializer(serializers.ModelSerializer):
buy_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', read_only=True)
sell_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', read_only=True)
class Meta:
model = xxx
exclude = ('id',)