How do I set a default, max and min value for an integerfield Django?

PositiveIntegerField ensures no integer less than 0 will be accepted. Your validators seem to handle the minimum and maximum values correctly. All you are missing is default for the default value. So something like

overs = models.PositiveIntegerField(default=10, validators=[MinValueValidator(1), MaxValueValidator(100)])

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)