Plugins not covered by get_absolute_url() #10724

Closed
opened 2025-12-29 21:35:13 +01:00 by adam · 3 comments
Owner

Originally created by @alehaa on GitHub (Feb 2, 2025).

Originally assigned to: @alehaa on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.2.2

Python Version

3.11

Steps to Reproduce

  1. Create example plugin skeleton.
  2. Add a custom model. Do not define get_absolute_url() as introduced by #17693 / NetBox v4.2.
  3. Run manage.py runserver
  4. Create new model object and save it.
  5. Run get_absolute_url() method of object.

Expected Behavior

The URL is returned.

Observed Behavior

An Exception is raised:

NoReverseMatch at /plugins/hello_world/foo/

'netbox_hello_world' is not a registered namespace

Originally created by @alehaa on GitHub (Feb 2, 2025). Originally assigned to: @alehaa on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.2.2 ### Python Version 3.11 ### Steps to Reproduce 1. Create example plugin skeleton. 2. Add a custom model. Do not define `get_absolute_url()` as introduced by #17693 / NetBox v4.2. 3. Run `manage.py runserver` 4. Create new model object and save it. 5. Run `get_absolute_url()` method of object. ### Expected Behavior The URL is returned. ### Observed Behavior An Exception is raised: > NoReverseMatch at /plugins/hello_world/foo/ > > 'netbox_hello_world' is not a registered namespace
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:35:13 +01:00
adam closed this issue 2025-12-29 21:35:13 +01:00
Author
Owner

@alehaa commented on GitHub (Feb 2, 2025):

PR #17693 added a generic get_absolute_url() method to NetBoxModel. However, plugins are in a different URL namespace than regular NetBox models. I think this is not covered yet.

To solve this problem, I suggest using get_viewname() utility function in get_absolute_url() instead of duplicating pathname creation. Maybe a test case can be added as well.

@alehaa commented on GitHub (Feb 2, 2025): PR #17693 added a generic `get_absolute_url()` method to `NetBoxModel`. However, plugins are in a different URL namespace than regular NetBox models. I think this is not covered yet. To solve this problem, I suggest using [`get_viewname()` utility function](https://github.com/netbox-community/netbox/blob/main/netbox/utilities/views.py#L246) in `get_absolute_url()` instead of duplicating pathname creation. Maybe a test case can be added as well.
Author
Owner

@arthanson commented on GitHub (Feb 5, 2025):

This could be either a feature request or bug, leaving it as a bug for now.

@arthanson commented on GitHub (Feb 5, 2025): This could be either a feature request or bug, leaving it as a bug for now.
Author
Owner

@alehaa commented on GitHub (Feb 8, 2025):

@arthanson I volunteer to work on this issue.

@alehaa commented on GitHub (Feb 8, 2025): @arthanson I volunteer to work on this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10724