From b603c1fe7c7aa40b15a0e21dc09f873e81939314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sat, 7 Oct 2017 17:45:22 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20r=C3=A9cup=C3=A8re=20plus=20proprement?= =?UTF-8?q?=20l'id=20de=20l'instance=20en=20train=20d'=C3=AAtre=20=C3=A9di?= =?UTF-8?q?t=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/machines/forms.py b/machines/forms.py index c9a3873f..940b5041 100644 --- a/machines/forms.py +++ b/machines/forms.py @@ -65,7 +65,7 @@ class EditInterfaceForm(ModelForm): self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4" self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).annotate(mtype_id=F('ip_type__machinetype__id')) # Add it's own address - self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id')) + self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id')) if "machine" in self.fields: self.fields['machine'].queryset = Machine.objects.all().select_related('user') @@ -99,10 +99,10 @@ class BaseEditInterfaceForm(EditInterfaceForm): self.fields['type'].queryset = MachineType.objects.filter(ip_type__in=IpType.objects.filter(need_infra=False)) self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).filter(ip_type__in=IpType.objects.filter(need_infra=False)).annotate(mtype_id=F('ip_type__machinetype__id')) # Add it's own address - self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id')) + self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id')) else: self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).annotate(mtype_id=F('ip_type__machinetype__id')) - self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.fields['ipv4'].get_bound_field(self, 'ipv4').value()).annotate(mtype_id=F('ip_type__machinetype__id')) + self.fields['ipv4'].queryset |= IpList.objects.filter(id=self.instance.id).annotate(mtype_id=F('ip_type__machinetype__id')) class AliasForm(ModelForm): class Meta: