2009-06-05 9 views
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にアクセスしているだけですが、そこには大きな成功はありません。

お礼

答えて

7

POSTデータがself.dataに含まれています。

関連する問題