目前還正在做的代碼(從形式):Django ValidationError - 如何正確使用它?
# the exception that gets raised if the form is not valid
raise forms.ValidationError("there was an error");
# here is where form.is_valid is called
form.is_valid() == False:
response['msg']=str(form.errors)
response['err']='row not updated.'
json = simplejson.dumps(response) #this json will get returned from the view.
這裏的問題是,它發送錯誤號給客戶端:
- 「有一個錯誤。」
我想從返回的錯誤模板中刪除「全部」垃圾。我怎麼能這樣做呢?它似乎在django表單代碼中得到了深入。