Closed DanSheps closed 15 hours ago
The root cause is by default NetBoxAPIHyperlinkedIdentityField
and NetBoxURLHyperlinkedIdentityField
use a static definition for the defining the path.
Proposed fix would be to make the following changes:
class NetBoxAPIHyperlinkedIdentityField(BaseNetBoxHyperlinkedIdentityField):
- def get_view_name(self, app_name, model_name):
- return f'{app_name}-api:{model_name}-detail'
+ def get_view_name(self, model):
+ return get_viewname(model=model, action='detail', rest_api=True)
class NetBoxURLHyperlinkedIdentityField(BaseNetBoxHyperlinkedIdentityField):
- def get_view_name(self, app_name, model_name):
- return f'{app_name}:{model_name}'
+ def get_view_name(self, app_name, model_name):
+ return get_viewname(model=model)
class BaseNetBoxHyperlinkedIdentityField(serializers.HyperlinkedIdentityField):
- model_name = self.parent.Meta.model._meta.model_name
- app_name = self.parent.Meta.model._meta.app_label
- view_name = self.get_view_name(app_name, model_name)
+ view_name = self.get_view_name(obj)
Deployment Type
Self-hosted
NetBox Version
4.1.1
Python Version
3.12
Steps to Reproduce
url
is defined as a field but not overriddenExpected Behavior
url
will have a proper linkObserved Behavior
Exception: ImproperlyConfigured at