I’m adding a new DecimalField to my model, what value will it have by default in the database (if I don’t specify the default explicitly on the field e.g. default=1.23)?
amount = models.DecimalField(max_digits=15, decimal_places=3)
I’m expecting it will be either NULL or 0.0 (or None or Decimal(0.000) in python), but which?
Couldn’t find this mentioned in the docs: https://docs.djangoproject.com/en/2.2/ref/models/fields/#decimalfield
I’m using Django 2.2, but expect this is consistent across versions.
>Solution :
Django does not set any default values. You must specify the default value yourself.
amount = models.DecimalField(max_digits=15, decimal_places=3, default=0.0)