当表单无效时如何使用to_python保存已处理的数据?

时间:2011-09-26 16:45:02

标签: django forms

我有一个django形式,它可能无效,但我想在一些字段上使用to_python()方法处理数据,以便将其提交给用户,这样他就可以更改错误的字段,但已经处理过某些“好”字段的值。

f = MyForm(request.POST)
if f.is_valid():
    # not my case
return render_to_response('template.html', form)

和request.POST {'price':'100 000','duration':'aaa'} 使用to_python()处理{'price':'100000','duration':'aaa'} 我想用这个新的价格值(100000而不是100 000)填写render_to_response中的表格

0 个答案:

没有答案