Django序列化后返回数据 时间字段带T
2021-01-21T18:12:13
解决方案
class UserSerializer(serializers.ModelSerializer):
# 不加read_only=True 会限制post/put请求参数必传这两个字段
create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', read_only=True)
update_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', read_only=True)
class Meta:
model = User
fields = '__all__'
OK.