I have a Django model
from django.db import models
from django.contrib.postgres.fields import ArrayField
class Website(models.Model):
id = models.BigAutoField(primary_key=True, verbose_name='ID')
status = models.BooleanField(default=True)
meta = ArrayField(base_field=models.CharField(max_length=200, null=True), default=list)
I'm using following serializer to save data to the DB:
class WebsiteConfigSerializer(serializers.ModelSerializer):
class Meta:
model = Website
fields = ('status', 'meta')
When I'm trying to save the following data, I'm getting error:
{
"status": true,
"meta": []
}
#ERROR:
# "meta : This list may not be empty."
Is it not possible to save an empty list to an ArrayField ?
When I'm not passing the field at all, the value getting stored is {NULL}.
Also during initial migrations, since I had added a default value as list, all my existing entries had "meta" value as {}
If the empty list value is not allowed at all, how come this got saved during initial migration ?