gpt4 book ai didi

python - 'NoneType' 对象没有属性 'set_cookie'

转载 作者:太空宇宙 更新时间:2023-11-04 07:44:00 25 4
gpt4 key购买 nike

我在 python 中获得了 Formwizard 的以下 django 代码。首先有两种形式:

 class AuthenticationForm(forms.Form):
FirstName = forms.CharField(max_length=500)
LastName = forms.CharField(max_length=500)

class SurveyForm(forms.Form):
def __init__(self, *args, **kwargs):
super(SurveyForm, self).__init__(*args, **kwargs)
for question in choiceValue:
self.fields[question] = forms.ChoiceField(choices=CHOICES,widget=RadioSelect())

class ContactWizard(FormWizard):
choiceValue = []

def get_template(self,step):
if step == 0:
return 'wizard0.html'
if step == 1:
return 'wizard1.html'

def process_step(self, request, form, step):
if (step == 0):
fullName=""
if request.method== 'POST':
if form.is_valid():
FirstName = form.cleaned_data['FirstName']
LastName = form.cleaned_data['LastName']
FirstNameU=FirstName.capitalize()
LastNameU=LastName.capitalize()
fullName=FirstNameU+" "+LastNameU
personURIfn=GraphR.triples((None,FOAF_NS['givenName'],Literal(FirstNameU)))
personURIln=GraphR.triples((None,FOAF_NS['familyName'],Literal(LastNameU)))
for purifn in personURIfn:
purifnStr='%s' %purifn[0]
for puriln in personURIln:
purilnStr='%s' %puriln[0]
if purifnStr == purilnStr:
personURI=purifnStr
friendKnows=GraphR.triples((URIRef(purifnStr),FOAF_NS['knows'],None))
for fk in friendKnows: #and scn1 not in epuriList1:
fkStr='%s' %fk[2]
choiceValue.append(fkStr)
return render_to_response('wizard1.html', RequestContext(request))


def done(self, request, form_list):
print 'run'

我不明白为什么它给出标题中提到的错误。此外,谷歌也不提供任何具体帮助。你们中的任何人都可以猜出它的原因。我怀疑 Done 方法中发生了错误,但不确定。

谢谢。

最佳答案

如果不是第 0 步,或者它是 GET 而不是 POST,或者表单无效,请考虑 process_step 中会发生什么。在这些情况下会返回什么?

关于python - 'NoneType' 对象没有属性 'set_cookie',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12450838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com