Django 默认值
Django default value
如果我创建如下输入的字段,当表单上的字段留空时,默认值会保存到对象吗?
field_name = models.FloatField(default=100.0, blank=True)
关于模型字段的默认值:
The default value is used when new model instances are created and a
value isn’t provided for the field. When the field is a primary key,
the default is also used when the field is set to None.
https://docs.djangoproject.com/en/1.10/ref/models/fields/#default
如果我创建如下输入的字段,当表单上的字段留空时,默认值会保存到对象吗?
field_name = models.FloatField(default=100.0, blank=True)
关于模型字段的默认值:
The default value is used when new model instances are created and a value isn’t provided for the field. When the field is a primary key, the default is also used when the field is set to None.
https://docs.djangoproject.com/en/1.10/ref/models/fields/#default