您好我想知道是否可以从公式获取输入数据并将此数据用于其他函数?
my forms.py:
class TextPathForm(forms.Form):
text = forms.CharField(required=True)
language = forms.CharField(required=True)
stopwords = forms.CharField(required=False)
search = forms.CharField(required=False)
filterword = forms.CharField(required=False)
我的view.py:
def textpath(request):
success = False
text = ''
stopwords = ''
language = ''
search = ''
if request.method == 'POST':
textpath_form = TextPathForm(request.POST)
if textpath_form.is_valid():
success = True
text = textpath_form.cleaned_data['text']
stopwords = textpath_form.cleaned_data['stopwords']
language = textpath_form.cleaned_data['language']
search = textpath_form.cleaned_data['search']
else:
textpath_form = TextPathForm()
ctx = {'textpath_form':textpath_form,'text':text,'language':language,'stopwords':stopwords,'search':search,'succes': success,}
return render_to_response('index.html',ctx)
def any_function("need parameter text from textpath() "):
感谢您的帮助。
答案 0 :(得分:0)
textpath_form.cleaned_data
作为参数传递给您的函数,或者甚至通过textpath_form.cleaned_data['text']
并在那里执行某些操作。