Skip to content

Commit 34fb653

Browse files
committed
174 fix delete of CO on detail page
1 parent a850a9c commit 34fb653

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

netbox_custom_objects/views.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,19 @@ def get_object(self, **kwargs):
543543
model = object_type.get_model()
544544
return get_object_or_404(model.objects.all(), **self.kwargs)
545545

546+
def get_return_url(self, request, obj=None):
547+
"""
548+
Return the URL to redirect to after deleting a custom object.
549+
"""
550+
if obj:
551+
# Get the custom object type from the object directly
552+
custom_object_type = obj.custom_object_type.name
553+
else:
554+
# Fallback to getting it from kwargs if object is not available
555+
custom_object_type = self.kwargs.get("custom_object_type")
556+
557+
return reverse("plugins:netbox_custom_objects:customobject_list", kwargs={"custom_object_type": custom_object_type})
558+
546559

547560
@register_model_view(CustomObject, "bulk_edit", path="edit", detail=False)
548561
class CustomObjectBulkEditView(CustomObjectTableMixin, generic.BulkEditView):

0 commit comments

Comments
 (0)