1👍
✅
Try this:
class Schedule(models.Model):
name = models.CharField(max_length=100)
start_time = models.DateTimeField(auto_now_add=True)
end_time = models.DateTimeField(null=True, blank=True)
day_of_the_week = models.JSONField(default=list)
class ScheduleSerializer(serializers.ModelSerializer):
day_of_the_week = serializers.ListField(
child=serializers.IntegerField(),
)
class Meta():
model = Schedule
fields = "__all__"
0👍
Your solution should work with one small modification:
models.CharField(validators=[int_list_validator], max_length=100)
Source:stackexchange.com