Plugin Version
0.4.9
NetBox Version
4.5.7
Python Version
3.12.3
Steps to Reproduce
- Create a Custom Object Type with a
multiobject field (e.g. VM Dependencies → Virtualization > Virtual Machine)
- Create any Custom Object of that type
- Navigate to the object's detail page
- Click the "Delete" button
Expected Behavior
The object should be deleted successfully, or a confirmation page should be displayed before deletion.
Observed Behavior
A server error is raised immediately when clicking Delete:
<class 'ValueError'>
Cannot query "<object_name>": Must be "Table4Model" instance.
The error occurs in CustomObjectDeleteView when NetBox's _get_dependent_objects() uses Django's Collector to find related objects before showing the confirmation page. The Collector traverses M2M relations (e.g. multiobject fields) and passes the object's string representation instead of a proper model instance into the ORM query.
The object name in the error message always matches the name of the object being deleted, confirming the issue is in the delete view's dependent object resolution.
Workaround: Deletion works correctly via the Django shell:
from netbox_custom_objects.models import *
cot = CustomObjectType.objects.get(slug="<your-slug>")
model = cot.get_model()
obj = model.objects.get(id=<id>)
obj.delete()
Suggested fix — add _get_dependent_objects override to CustomObjectDeleteView in views.py:
def _get_dependent_objects(self, obj):
try:
return super()._get_dependent_objects(obj)
except ValueError:
return {}
Plugin Version
0.4.9
NetBox Version
4.5.7
Python Version
3.12.3
Steps to Reproduce
multiobjectfield (e.g. VM Dependencies → Virtualization > Virtual Machine)Expected Behavior
The object should be deleted successfully, or a confirmation page should be displayed before deletion.
Observed Behavior
A server error is raised immediately when clicking Delete:
The error occurs in
CustomObjectDeleteViewwhen NetBox's_get_dependent_objects()uses Django'sCollectorto find related objects before showing the confirmation page. The Collector traverses M2M relations (e.g.multiobjectfields) and passes the object's string representation instead of a proper model instance into the ORM query.The object name in the error message always matches the name of the object being deleted, confirming the issue is in the delete view's dependent object resolution.
Workaround: Deletion works correctly via the Django shell:
Suggested fix — add
_get_dependent_objectsoverride toCustomObjectDeleteViewinviews.py: