Some way to use forms in views:
blank form or form with some content:
if request.method=='GET':
form1=SelectForm(request.GET)
else:
form1=SelectForm()
And than we send to form necessary corteges for "select" elements (each cortege include few two-elements cortege and like as ((,),(,),(,),...,(,)) ):
form1.fields['select1'].
choices=((1,'First'),(2,' Second'),(3,'Third'))
We can get data from form:
datas=[]
if form1.is_valid():
datas=form1.cleaned_data
dd=datas['select2']
blank form or form with some content:
if request.method=='GET':
form1=SelectForm(request.GET)
else:
form1=SelectForm()
And than we send to form necessary corteges for "select" elements (each cortege include few two-elements cortege and like as ((,),(,),(,),...,(,)) ):
form1.fields['select1'].
We can get data from form:
datas=[]
if form1.is_valid():
datas=form1.cleaned_data
dd=datas['select2']
( format of the value "cleaned_data" is dict() )
Комментариев нет:
Отправить комментарий