0
안녕하세요 저는 공식에서 입력 데이터를 가져 와서이 데이터를 다른 함수에 사용할 수 있는지 알고 싶습니까?공식에서 입력 데이터를 가져와 함수의 매개 변수로 사용
내 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() "):
감사합니다.
시도한 경우 : def any_function (textpath_form.cleaned_data) : SyntaxError가 발생합니다. 또는 def any_function (x = textpath_form.cleaned_data) : -> NameError text_path가 정의되지 않았습니다. – SnowBallz
아니요, 아니요. 'def any_function (data)'를 수행 한 다음'any_function (textpath_form.cleaned_data)'와 같이 요청할 때 사용하십시오. 데이터를 저장하고 싶다면 외부 요청'any_function (textpath_form.cleaned_data)'를 사용할 수 있도록 전역 변수 나 데이터베이스에 저장해야합니다. – freakish
아, 이제 알겠습니다. 감사. – SnowBallz