From 72938dcb58c42cd9a7386ccb55c79780cbc908db Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Mon, 13 Mar 2023 15:27:24 -0600 Subject: [PATCH] Add clean function for variant weight to be zero when form blank --- dashboard/forms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dashboard/forms.py b/dashboard/forms.py index 36e738e..5348f35 100644 --- a/dashboard/forms.py +++ b/dashboard/forms.py @@ -37,6 +37,13 @@ class ProductVariantUpdateForm(forms.ModelForm): product=self.instance.product ) + def clean_weight(self): + data = self.cleaned_data['weight'] + if not data: + data = 0 + + return data + class CouponForm(forms.ModelForm): class Meta: