Django 当表单无效时,如何将处理过的数据保存到python?

Django 当表单无效时,如何将处理过的数据保存到python?,django,forms,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':'100000','duration':'aaa'}

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

f = MyForm(request.POST)
if f.is_valid():
    # not my case
return render_to_response('template.html', form)
和request.POST{'price':'100000','duration':'aaa'} 使用to_python()处理为{'price':'100000','duration':'aaa'}
我想用这个新的价格值(100000而不是100000)来填充render\u to\u response中的表单。

你不能像返回render\u to\u response('template.html',f)那样返回处理过的表单吗?不,因为在这种情况下,我不能用to\u python()方法处理价格值,因为表单无效。