From d4d355dce6f196ff34f144dfeae6b894eddeba60 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 1 May 2019 12:02:18 -0400 Subject: [PATCH] Fixes #3130: Fix exception when creating a new power outlet --- CHANGELOG.md | 1 + netbox/dcim/forms.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf2c3c7b..7a839ec92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ v2.6.0 (FUTURE) * [#3123](https://github.com/digitalocean/netbox/issues/3123) - Exempt `/metrics` view from authentication * [#3125](https://github.com/digitalocean/netbox/issues/3125) - Fix exception when viewing PDUs * [#3126](https://github.com/digitalocean/netbox/issues/3126) - Incorrect calculation of PowerFeed available power +* [#3130](https://github.com/digitalocean/netbox/issues/3130) - Fix exception when creating a new power outlet --- diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 99ecec2d6..025b51e79 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -2006,9 +2006,10 @@ class PowerOutletForm(BootstrapMixin, forms.ModelForm): super().__init__(*args, **kwargs) # Limit power_port choices to the local device - self.fields['power_port'].queryset = PowerPort.objects.filter( - device=self.instance.device - ) + if hasattr(self.instance, 'device'): + self.fields['power_port'].queryset = PowerPort.objects.filter( + device=self.instance.device + ) class PowerOutletCreateForm(ComponentForm):