I\'m storing some floating-point data in my Django models, and only a certain range of values are meaningful. Therefore, I\'d like to impose these limits at both the model a
The answers so far describe how to make forms validate. You can also put validators in the model. Use MinValueValidator and MaxValueValidator.
For example:
from django.core.validators import MaxValueValidator, MinValueValidator
...
weight = models.FloatField(
validators=[MinValueValidator(0.9), MaxValueValidator(58)],
)
I don't think that adds SQL constraints, tho.