I'm trying to implement the IntegerRangeField() for an age range field. Unfortunately the documentation doesn't say how to validate the upper and lower bounds.
I tried it from the model like so:
class SomeModel(models.Model):
age_range = IntegerRangeField(default='(0,100)', blank=True, validators=[MinValueValidator(1), MaxValueValidator(100)])
The problem is, no matter what you put in the field, Django throws a ValidationError:
The value must be less than or equal to 100
Also if I put nothing in the field, it doesn't put the default range, and fails, complaining about an IntegrityError.
So, I tried doing this from the form object:
class SomeForm(forms.ModelForm):
age_range = IntegerRangeField(validators=[MinValueValidator(1), MaxValueValidator(100)])
But that does nothing at all. Any figure I put in the fields saves. What am I doing wrong?