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 ?

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the quick answer, I guess I'll have to manually restrict the values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.