0

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 do something wrong ?

Community
  • 1
  • 1

1 Answers1

2

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358