Sfoglia il codice sorgente

#6732 - Fix test exception in Site form

Daniel Sheppard 4 anni fa
parent
commit
7c147db324
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      netbox/dcim/forms/models.py

+ 2 - 1
netbox/dcim/forms/models.py

@@ -175,7 +175,8 @@ class SiteForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
     def __init__(self, data=None, instance=None, *args, **kwargs):
     def __init__(self, data=None, instance=None, *args, **kwargs):
         super().__init__(data=data, instance=instance, *args, **kwargs)
         super().__init__(data=data, instance=instance, *args, **kwargs)
 
 
-        self.fields['asns'].initial = self.instance.asns.all().values_list('id', flat=True)
+        if self.instance and self.instance.pk is not None:
+            self.fields['asns'].initial = self.instance.asns.all().values_list('id', flat=True)
 
 
         # Hide the ASN field if there is nothing there as this is deprecated
         # Hide the ASN field if there is nothing there as this is deprecated
         if instance is None or \
         if instance is None or \