mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-23 17:28:49 +02:00
fix(dcim): Use hasattr check for virtual_circuit_termination (#21811)
Replace direct attribute access with hasattr() to prevent AttributeError when the virtual_circuit_termination relation doesn't exist on the object. Fixes #21808
This commit is contained in:
@@ -541,7 +541,7 @@ class VirtualCircuitPanel(panels.ObjectPanel):
|
|||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
obj = context.get('object')
|
obj = context.get('object')
|
||||||
if not obj or not obj.is_virtual or not obj.virtual_circuit_termination:
|
if not obj or not obj.is_virtual or not hasattr(obj, 'virtual_circuit_termination'):
|
||||||
return ''
|
return ''
|
||||||
ctx = self.get_context(context)
|
ctx = self.get_context(context)
|
||||||
return render_to_string(self.template_name, ctx, request=ctx.get('request'))
|
return render_to_string(self.template_name, ctx, request=ctx.get('request'))
|
||||||
|
|||||||
Reference in New Issue
Block a user