Is there an easy way to access the POST variable to perform some random checks in the method of cleaning the admin form field?
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
I need to capture a post-provider variable that is not in this form, cleared data, because the provider field is part of the parent form. The only way I can get to grips is to access request.POST, but it doesn't have much success there.
Thanks
source
share