开发者

django models IntegerFields limits not working

开发者 https://www.devze.com 2023-03-20 11:58 出处:网络
I\'m trying to limit the possible values of an IntegerField in my Django model. I have read through this :

I'm trying to limit the possible values of an IntegerField in my Django model.

I have read through this : How to limit the maximum value of a numeric field in a Django model?

...and this : Set Django IntegerField by choices=... name

and tried both.

Unfortunately, when I manually set the value of the field outside of the boundaries, then save the object, no exception is raised and the value is really stored.

Did I misunderstand how it worked, or did I d开发者_开发知识库o something wrong ?


The limits are applied to fields in a ModelForm; they are not enforced at the model or database level (although they conceivably could be).

0

精彩评论

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