Django 5.1 models with fields using db_default throw on full_clean
Trying to implement Django 5's new db_default attribute for fields
Using the following field as an example:
editable = models.BooleanField(db_default=True)
Would expect that if editable not specified when creating a new instance, that ORM would not throw error but would still save instance, and that the value of editable would be set to True at the database level.
So executing the following to create a new object:
product_obj = models.Product(
id=id,
name=name,
is_active=is_active,
inventory_type=inventory_type,
leadtime=leadtime,
)
product_obj.full_clean()
product_obj.save()
would be expected to succeed.
Instead full_clean() raises a ValidationError:
django.core.exceptions.ValidationError: {'editable': ['“<django.db.models.expressions.DatabaseDefault object at 0x151db1c70>” value must be either True or False.']}
and similar behavior occurs throughout my codebase for any field for which db_default is set (CharField with choices, IntegerField, etc)
Clearly I'm not understanding how db_default should be used.