且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获得Django模型中字段的默认值?

更新时间:2023-01-30 10:54:45

您可以像这样获得字段:

You can get the field like this:

myfield = MyModel._meta.get_field_by_name('field_name')

,默认值只是该字段的属性:

and the default is just an attribute of the field:

myfield.default