2
The field data should be obtained from the form’s cleaned_data
dictionary:
def clean(self):
item = self.cleaned_data['item']
quantity = self.cleaned_data['quantity']
if(quantity > item.inventory):
raise ValidationError("Insufficient inventory")
Source:stackexchange.com