The default bound of Django range fields is [)
. This package follows default bounds as []
.
pip install inclusive-django-range-fields
# models.py
from django.db import models
from inclusive_django_range_fields import InclusiveIntegerRangeField
class AdCampaign(models.Model):
age_target = InclusiveIntegerRangeField()
>> AdCampaign.objects.first().age_target
NumericRange(18, 30, '[]')
# serializers.py
from rest_framework import serializers
from inclusive_django_range_fields.drf import InclusiveIntegerRangeField
class AdCampaignSerializer(serializers.ModelSerializer):
age_target = InclusiveIntegerRangeField()
class Meta:
model = AdCampaign
fields = (
"id",
"age_target",
)
{
"id": 1993,
"age_target": {
"lower": 18,
"upper": 30
}
}
inclusive_django_range_fields.InclusiveIntegerRangeField
inclusive_django_range_fields.InclusiveBigIntegerRangeField
inclusive_django_range_fields.InclusiveDateRangeField
inclusive_django_range_fields.InclusiveNumericRange
inclusive_django_range_fields.InclusiveDateRange
inclusive_django_range_fields.InclusiveDateTimeTZRange
inclusive_django_range_fields.drf.InclusiveIntegerRangeField
inclusive_django_range_fields.drf.InclusiveDateRangeField
inclusive_django_range_fields.InclusiveIntegerRangeFormField
inclusive_django_range_fields.InclusiveDateRangeFormField