Default value can be assigned for forms.DecimalField? Is it has to be already assigned in model declaration?

Wherever I try to give a default value to this field, which is supposed to be outside of my model gives error saying "default" or "attr" argument is unexpected.

    log_duration_minute = forms.DecimalField(
        help_text=_("log_duration_helper_text_minute"),
        default="0.00",
    )

The error message:

    __init__() got an unexpected keyword argument 'default'

You can use default values in the model, but when defining a form field use initial =

You may also want to

from decimal import Decimal

so that you can use

initial = Decimal('0.00')
Back to Top