change a form value before validation in Django form

前端 未结 4 1380
难免孤独
难免孤独 2021-02-19 03:00

I have a django form and on my view function I do this :

search_packages_form = SearchPackagesForm( data = request.POST )

I would like to overw

4条回答
  •  广开言路
    2021-02-19 03:16

    one trick for what you want is to do it like this:

    changed_data = dict(request.POST)
    changed_data['price'] = NEW_PRICE
    search_packages_form = SearchPackagesForm(data = changed_data)
    

提交回复
热议问题