Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins not covered by get_absolute_url() #18555

Closed
alehaa opened this issue Feb 2, 2025 · 3 comments · Fixed by #18607
Closed

Plugins not covered by get_absolute_url() #18555

alehaa opened this issue Feb 2, 2025 · 3 comments · Fixed by #18607
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@alehaa
Copy link
Contributor

alehaa commented Feb 2, 2025

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 16546 define get_absolute_url method in NetBoxModel #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

@alehaa alehaa added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Feb 2, 2025
@alehaa
Copy link
Contributor Author

alehaa commented 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.

@arthanson
Copy link
Collaborator

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

@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Feb 5, 2025
@alehaa
Copy link
Contributor Author

alehaa commented Feb 7, 2025

@arthanson I volunteer to work on this issue.

@DanSheps DanSheps added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants