File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,11 @@ precedence when creating instances in Python code. ``db_default`` will still be
426
426
set at the database level and will be used when inserting rows outside of the
427
427
ORM or when adding a new field in a migration.
428
428
429
+ If a field has a ``db_default`` without a ``default`` set and no value is
430
+ assigned to the field, a ``DatabaseDefault`` object is returned as the field
431
+ value on unsaved model instances. The actual value for the field is determined
432
+ by the database when the model instance is saved.
433
+
429
434
``db_index``
430
435
------------
431
436
Original file line number Diff line number Diff line change @@ -224,6 +224,15 @@ ones:
224
224
object. If callable it will be called every time a new object is
225
225
created.
226
226
227
+ :attr:`~Field.db_default`
228
+ The database-computed default value for the field. This can be a literal
229
+ value or a database function.
230
+
231
+ If both ``db_default`` and :attr:`Field.default` are set, ``default`` will
232
+ take precedence when creating instances in Python code. ``db_default`` will
233
+ still be set at the database level and will be used when inserting rows
234
+ outside of the ORM or when adding a new field in a migration.
235
+
227
236
:attr:`~Field.help_text`
228
237
Extra "help" text to be displayed with the form widget. It's useful for
229
238
documentation even if your field isn't used on a form.
You can’t perform that action at this time.
0 commit comments