Django set field value after a form is initialized

后端 未结 9 1940
陌清茗
陌清茗 2020-12-12 14:50

I am trying to set the field to a certain value after the form is initialized.

For example, I have the following class.

class CustomForm(forms.Form)         


        
9条回答
  •  猫巷女王i
    2020-12-12 15:22

    If you've already initialized the form, you can use the initial property of the field. For example,

    form = CustomForm()
    form.fields["Email"].initial = GetEmailString()
    

提交回复
热议问题