3
管理フォームフィールドのクリーンメソッドでいくつかのカスタム検証ルックアップを完了するためのPOST変数に簡単にアクセスできますか?私が取得する必要があり何フォームのclean()メソッドでPOST変数を取得する
def clean_order_price(self):
if not self.cleaned_data['order_price']:
try:
existing_price = ProductCostPrice.objects.get(supplier=supplier, product_id=self.cleaned_data['product'], is_latest=True)
except ProductCostPrice.DoesNotExist:
existing_price = None
if not existing_price:
raise forms.ValidationError('No match found, please enter new price')
else:
return existing_price.cost_price_gross
else:
return self.cleaned_data
サプライヤーとのフィールドは、親フォームの一部であるため、このフォームのクリーンデータではありません「サプライヤー」ポスト変数です。私がそれをつかむことがわかることができるのは、request.POSTにアクセスしているだけですが、そこには大きな成功はありません。
お礼