get_absolute_url() not working correctly for plugin #10975

Closed
opened 2025-12-29 21:38:42 +01:00 by adam · 1 comment
Owner

Originally created by @peteeckel on GitHub (Apr 2, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.2.6

Python Version

3.11

Steps to Reproduce

  1. Remove the plugin-specific get_absolute_url() method from a plugin model (e.g. NetBox DNS Zone) so that the new method provided in #18607 gets inherited
  2. Run /opt/netbox/netbox/manage.py nbshell
  3. Use the following commands to retrieve the result of get_absolute_url:
from netbox_dns.models import Zone
z=Zone.objects.first()
z.get_absolute_url()

Expected Behavior

The absolute URL for the object is returned, e.g.

'/plugins/netbox-dns/zones/8/'

Observed Behavior

>>> from netbox_dns.models import Zone
>>> z=Zone.objects.first()
>>> z.get_absolute_url()
Traceback (most recent call last):
  File "/opt/netbox/lib64/python3.11/site-packages/django/urls/base.py", line 81, in reverse
    extra, resolver = resolver.namespace_dict[ns]
                      ~~~~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: 'netbox_dns'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.11/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/opt/netbox/netbox/netbox/models/__init__.py", line 45, in get_absolute_url
    return reverse(f'{self._meta.app_label}:{self._meta.model_name}', args=[self.pk])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/lib64/python3.11/site-packages/django/urls/base.py", line 92, in reverse
    raise NoReverseMatch("%s is not a registered namespace" % key)
django.urls.exceptions.NoReverseMatch: 'netbox_dns' is not a registered namespace
Originally created by @peteeckel on GitHub (Apr 2, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.2.6 ### Python Version 3.11 ### Steps to Reproduce 1. Remove the plugin-specific `get_absolute_url()` method from a plugin model (e.g. NetBox DNS `Zone`) so that the new method provided in #18607 gets inherited 2. Run `/opt/netbox/netbox/manage.py nbshell` 3. Use the following commands to retrieve the result of `get_absolute_url`: ```python from netbox_dns.models import Zone z=Zone.objects.first() z.get_absolute_url() ``` ### Expected Behavior The absolute URL for the object is returned, e.g. ``` '/plugins/netbox-dns/zones/8/' ``` ### Observed Behavior ``` >>> from netbox_dns.models import Zone >>> z=Zone.objects.first() >>> z.get_absolute_url() Traceback (most recent call last): File "/opt/netbox/lib64/python3.11/site-packages/django/urls/base.py", line 81, in reverse extra, resolver = resolver.namespace_dict[ns] ~~~~~~~~~~~~~~~~~~~~~~~^^^^ KeyError: 'netbox_dns' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib64/python3.11/code.py", line 90, in runcode exec(code, self.locals) File "<console>", line 1, in <module> File "/opt/netbox/netbox/netbox/models/__init__.py", line 45, in get_absolute_url return reverse(f'{self._meta.app_label}:{self._meta.model_name}', args=[self.pk]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/lib64/python3.11/site-packages/django/urls/base.py", line 92, in reverse raise NoReverseMatch("%s is not a registered namespace" % key) django.urls.exceptions.NoReverseMatch: 'netbox_dns' is not a registered namespace ```
adam added the type: bug label 2025-12-29 21:38:42 +01:00
adam closed this issue 2025-12-29 21:38:42 +01:00
Author
Owner

@peteeckel commented on GitHub (Apr 2, 2025):

Stop - my fault. I tested on the feature branch that hasn't been rebased beyond 4.2.3 yet.

@peteeckel commented on GitHub (Apr 2, 2025): Stop - my fault. I tested on the `feature` branch that hasn't been rebased beyond 4.2.3 yet.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10975