https://stackoverflow.com/questions/42239818/how-to-set-the-default-of-a-jsonfield-to-empty-list-in-django-and-django-jsonfie
def jsonfield_default_value():
default = {'id': 1, 'value': '안전하게 배송 부탁드려요'}
return default
class Address(BaseModel):
name = models.CharField(max_length=100, verbose_name="주소")
recipient = models.CharField(max_length=20, verbose_name="받는 사람")
phone_number = models.CharField(max_length=20, verbose_name="연락처")
delivery_memo = models.JSONField(default=jsonfield_default_value, verbose_name="요청 사항")
is_default = models.BooleanField(default=False, verbose_name="기본 배송지")
is_visitable = models.BooleanField(default=False, verbose_name="방문 수거 가능 여부")
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
def __str__(self):
return self.name