One, in HTML | Safe can be processed in the background in the following ways
1 " <input type ' text '/> " 2 from Import Mark_safe 3 Text = Mark_safe (text)
Second, views.py operation
1 fromDjango.shortcutsImportRender2 3 fromDjangoImportForms4 fromDjango.formsImportfields,widgets5 fromApp01ImportModels6 classLoveform (forms. Form):7Price =Fields . Integerfield ()8USER_ID =Fields . Integerfield (9 #widget=widgets. Select (choices=[(1, ' Alex '), (2, ' Xialv '), (3, ' SB '),])Ten #Database Fetch value Onewidget=widgets. Select () A ) - #set up dynamic bindings to update data at any time - def __init__(self,*args,**Kwargs): the #super must be in front, copy all the static fields, copy to Self.fields -Super (Loveform,self).__init__(*args,**Kwargs) -self.fields['user_id'].widget.choices = models. UserInfo.objects.values_list ('ID','username') - + defLove (Request): -obj =Loveform () + returnRender (Request,'love.html', locals ())
West Tour Road--python full Stack--form component fields and dynamic bindings