出于调试目的,我需要为整个表单禁用字段验证,因此它始终有效。
我尝试了什么:
clean()
和full_clean()
方法,但似乎是我的
view的语句return render_to_response()
不会调用这样的方法,我也不能直接从视图中调用任何表单方法(idk why)required=False
,但我不知道为什么它不会在特定字段上工作(也许它需要db才能重新生成?...)或者我不知道如何将它设置为全部批量字段form._errors
dict,就像那样:self._errors = ErrorDict()
,但我不知道在哪里写它。 视图:
def step_1(request, vac_id):
b_fl = False
try:
if request.META['HTTP_REFERER'].find(u'step-2') == -1:
b_fl = True
except:
b_fl = True
if b_fl:
for key in res_keys:
for skey in res_keys[key]:
if skey in request.session:
del request.session[skey]
if vac_id:
vacancy = Vacancy.objects.get(pk=vac_id)
else:
vacancy = None
res_list = {}
for i in res_keys[1]:
if i in request.session:
res_list[i] = request.session[i]
else:
res_list[i] = None
if 'vac_id' in request.session:
vac_id = int(request.session['vac_id'])
if vac_id:
pr_vacancy = Vacancy.objects.get(pk=vac_id)
else:
pr_vacancy = None
else:
pr_vacancy = None
if 'vac_text' in request.session:
vac_text = request.session['vac_text']
else:
vac_text = None
return render_to_response('step_1.html',
{'vacancy': vacancy,
'res_list': res_list,
'pr_vacancy': pr_vacancy,
'vac_text': vac_text
},
context_instance=RequestContext(request))
形式:
class FeedbackForm(forms.Form):
vacancy = forms.IntegerField(required=False)
vacancy_text = forms.CharField(required=False)
salary_min = forms.CharField()
salary_opt = forms.CharField()
<..>
<lots of fields here>
<..>
recommendations = forms.ModelMultipleChoiceField(required=False)
dis_rec_reas = forms.CharField(max_length=255, required=False)
how_about_us = forms.CharField(required=False)
答案 0 :(得分:0)
好的,似乎所有上述解决方案都不起作用,因为该表格根本没有使用:D所有工作都在view-n-template之间完成。
如果我现在应该删除这个问题,请等待.. o_0