我有一个 django 表单,在我的视图函数中我这样做:
search_packages_form = SearchPackagesForm( data = request.POST )
我想覆盖一个名为 price 的表单字段,该字段已被取消:
price = forms.ChoiceField( choices = PRICE_CHOICES, required = False,widget = forms.RadioSelect )
我想在调用之前覆盖表单域search_packages_form.is_valid()
我想过这样做:
search_packages_form.data['price'] = NEW_PRICE
但它不起作用。有任何想法吗 ?