Explorar o código

Fixes #21320: Prevent Rack validation errors when site or optional fields are missing during import (#21321)

Martin Hauser hai 1 semana
pai
achega
ee6cbdcefe
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      netbox/dcim/models/racks.py

+ 1 - 1
netbox/dcim/models/racks.py

@@ -373,7 +373,7 @@ class Rack(ContactsMixin, ImageAttachmentsMixin, TrackingModelMixin, RackBase):
         super().clean()
 
         # Validate location/site assignment
-        if self.site and self.location and self.location.site != self.site:
+        if self.site_id and self.location_id and self.location.site_id != self.site_id:
             raise ValidationError(_("Assigned location must belong to parent site ({site}).").format(site=self.site))
 
         # Validate outer dimensions and unit