django解决Object of type Decimal is not JSON serializable
class DecimalEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, decimal.Decimal):
return float(o)
super(DecimalEncoder, self).default(o)
下边进行调用上边定义好的方法就好了
json.dumps(price, cls= DecimalEncoder)