From bac0a46ca27793dc3f76e758651f2ebd9db462f9 Mon Sep 17 00:00:00 2001 From: nanoy Date: Mon, 17 Dec 2018 08:42:44 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20du=20formulaire=20de=20f=C3=BBt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seuls les bons types de produits sont proposés dans les champs pinte, demi et galopin. Close #16 --- gestion/forms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gestion/forms.py b/gestion/forms.py index 3a45780..95894b7 100644 --- a/gestion/forms.py +++ b/gestion/forms.py @@ -32,6 +32,12 @@ class ProductForm(forms.ModelForm): fields = "__all__" class KegForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super(KegForm, self).__init__(*args, **kwargs) + self.fields['pinte'].queryset = Product.objects.filter(category=Product.P_PRESSION) + self.fields['demi'].queryset = Product.objects.filter(category=Product.D_PRESSION) + self.fields['galopin'].queryset = Product.objects.filter(category=Product.G_PRESSION) + class Meta: model = Keg exclude = ("is_active", )