How do I get the default value for a field in a Django model?

Viewed 14762

I have a Django model with some fields that have default values specified. I am looking to grab the default value for one of these fields for us later on in my code. Is there an easy way to grab a particular field's default value from a model?

5 Answers

if you don't want to write the field name explicitly, you can also do this: MyModel._meta.get_field(MyModel.field.field_name).default

Related