I have a model with two fields: min_age
, max_age
. And I need to filter it with Django Filters by range of two fields. How can I do that?
# models.py
class AdvertisementModelMixin(models.Model):
min_age = models.PositiveSmallIntegerField(
blank=True,
null=True,
validators=[
MaxValueValidator(80)
]
)
max_age = models.PositiveSmallIntegerField(
blank=True,
null=True,
validators=[
MaxValueValidator(80)
]
)
You can create a custom filter with:
or for nullable's: