Modify value of a Django form field during clean()

前端 未结 7 1467
陌清茗
陌清茗 2020-12-29 04:42

I am adding custom validation to my forms and custom fields in my Django app. I would like to be able to modify the value of a field when triggering an error. For example, i

7条回答
  •  囚心锁ツ
    2020-12-29 05:35

    Way to update value in clean() is update the value in form's data dictionary:

    self.data["a34_stuff"] = "html"
    

    This works for sure.

提交回复
热议问题