Django set field value after a form is initialized

后端 未结 9 1936
陌清茗
陌清茗 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条回答
  •  悲&欢浪女
    2020-12-12 15:26

    Another way to do this, if you have already initialised a form (with or without data), and you need to add further data before displaying it:

    form = Form(request.POST.form)
    form.data['Email'] = GetEmailString()
    

提交回复
热议问题