What is the default range for IntegerFields on Django?

Viewed 643

Such a simple question, but can't seem to find anything in the documentation about it.

For example, can integers be negative?

2 Answers

If you're talking about models.IntegerField then there is indeed a range for that and it is mentioned in the documentation.

An integer. Values from -2147483648 to 2147483647 are safe in all databases supported by Django.

It uses MinValueValidator and MaxValueValidator to validate the input based on the values that the default database supports.

If you're talking about forms.IntegerField, then the only way to validate it is to pass a parameter of max_value and min_value for that.

Validates that the given value is an integer. Uses MaxValueValidator and MinValueValidator if max_value and min_value are provided.

Related