开发者

how to keep processed data with to_python when form is not valid?

开发者 https://www.devze.com 2023-04-07 10:49 出处:网络
I have a django form which can be not valid, but I would like to keep the data processed with to_python() method on some fields to propose it to the user, so that he can changes wrong fields, but havi

I have a django form which can be not valid, but I would like to keep the data processed with to_python() method on some fields to propose it to the user, so that he can changes wrong fields, but having already processed values for some 'good' fields.

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

and request.POST {'开发者_开发问答price':'100 000', 'duration':'aaa'} is processed with to_python() to {'price':'100000', 'duration':'aaa'} and I would like to fill the form in render_to_response with this new price value (100000 and not 100 000)

0

精彩评论

暂无评论...
验证码 换一张
取 消