Deleting a single device role raises exception #4772

Closed
opened 2025-12-29 19:20:20 +01:00 by adam · 1 comment
Owner

Originally created by @rodvand on GitHub (Apr 15, 2021).

NetBox version

v2.10.10

Python version

3.8

Steps to Reproduce

  1. Add a Device Role "Device Role A"
  2. Assign the device role to a device or VM
  3. Go to Devices -> Device Roles
  4. Find "Device Role A" and click the delete icon on the right hand side
  5. Confirm deletion

Expected Behavior

An error saying you can't delete the role due to it being assigned to device(s).

Observed Behavior

An AttributeError is raised. 'DeviceRole' object has no attribute 'get_absolute_url'

This is working as expected in the 2.11-beta.

Originally created by @rodvand on GitHub (Apr 15, 2021). ### NetBox version v2.10.10 ### Python version 3.8 ### Steps to Reproduce 1. Add a Device Role "Device Role A" 2. Assign the device role to a device or VM 3. Go to Devices -> Device Roles 4. Find "Device Role A" and click the delete icon on the right hand side 5. Confirm deletion ### Expected Behavior An error saying you can't delete the role due to it being assigned to device(s). ### Observed Behavior An AttributeError is raised. 'DeviceRole' object has no attribute 'get_absolute_url' This is working as expected in the 2.11-beta.
adam added the type: bug label 2025-12-29 19:20:20 +01:00
adam closed this issue 2025-12-29 19:20:20 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 16, 2021):

Looks like this bug has been lurking around for a while. The exception is indeed triggered because the DeviceRole model lacks a get_absolute_url() method. The ipam.Role model would have the same issue, except that we allow roles to be deleted even if assigned to prefixes and/or VLANs (the assignment gets nullified).

A workaround to this is to select the desired device role(s) from the list and click the "delete selected" button at the bottom of the page: The bulk edit functionality doesn't trigger the error. Given that a viable workaround exists and this is effectively fixed in the upcoming v2.11.0 release, I'm going to close this out. I appreciate the report though!

@jeremystretch commented on GitHub (Apr 16, 2021): Looks like this bug has been lurking around for a while. The exception is indeed triggered because the DeviceRole model lacks a `get_absolute_url()` method. The ipam.Role model would have the same issue, except that we allow roles to be deleted even if assigned to prefixes and/or VLANs (the assignment gets nullified). A workaround to this is to select the desired device role(s) from the list and click the "delete selected" button at the bottom of the page: The bulk edit functionality doesn't trigger the error. Given that a viable workaround exists and this is effectively fixed in the upcoming v2.11.0 release, I'm going to close this out. I appreciate the report though!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4772