用例:想要存储0.0
为默认值,而没有为 a 传递任何pewee
值DoubleField
。我编写了以下代码,但对我不起作用。
class MyRelation(peewee.Model):
id = peewee.PrimaryKeyField()
percentage = peewee.DoubleField(default=0.0)
这是一个api
@api_blueprint.route('/add_data', methods=['POST'])
@http_header
def add_data():
try:
incoming = json.loads(request.data)
data = MyRelation(percentage=incoming["percentage"])
data.save()
return success_response(201,"Data has been inserted :)")
except Exception as e:
log(str(e))
return raise_error(500, str(e))
记录以下错误
10-05-17 05:24:51 Line:199 Message: Error in add_data(),views.api: (1048, "Column 'percentage' cannot be null")