开发者

Setting default value for integer field in django models

开发者 https://www.devze.com 2023-03-26 16:27 出处:网络
I\'m trying to set a default value for the integer field in Django model using models.Pos开发者_高级运维itiveSmallIntegerField(default=\'0\')

I'm trying to set a default value for the integer field in Django model using

models.Pos开发者_高级运维itiveSmallIntegerField(default='0')

Why isn't it working?


The default value in your example is set to string ('0'), but it should be integer. Try this instead:

models.PositiveSmallIntegerField(default=0)
0

精彩评论

暂无评论...
验证码 换一张
取 消