Django DB level default value for a column

前端 未结 1 679
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 01:07

Django is proving the model field argument default (https://docs.djangoproject.com/en/dev/ref/models/fields/#default) but as I know it will be called every time new object i

相关标签:
1条回答
  • 2020-12-19 01:23

    There is an open ticket 470 to include default values in the SQL schema.

    Until this feature has been added to Django, you'll have to manually run alter table statements yourself or write a migration to run them if you want a default value in the SQL schema.

    Note that Django allows callables as defaults, so even if this feature is added to Django, it won't be possible to have all defaults in the database.

    0 讨论(0)
提交回复
热议问题