Custom plugin, ButtonsColumn and namespace errors #7390
-
I suspect I'm going to be told I'm dabbling with private classes and should steer well clear, but here goes... I'm working on a custom plugin for NetBox 3.0.3. The custom plugin presents a list of objects and I'd like to present a familiar UI/UX as the other built in lists. I've defined a table class inheriting from BaseTable and I'm able to render it using a subclass of generic.ObjectListView. I tried to add a ButtonsColumn(MyModel) so I could have the standard set of changelog, edit and delete buttons and then I hit problems with 'plugin_name is not a registered namespace' errors. I tracked this down to the template code that renders the changelog, edit and delete buttons and, with plenty of googling, managed to work out that my plugin's namespace was 'plugins:plugin_name' not just 'plugin_name'. Consequently the template was unable to render my links and fell over. I've been able to workaround this by subclassing the ButtonColumn class and adding 'plugins:' before the {app_label}:{model_name} in the links, but this feels clunky. Is this my only option? Can I/should I somehow be changing the app_label? I'd very much like to keep my UX consistent with the native tables and therefore just create suitably named views that can be called by the 'built in' templates if that is somehow possible. Is there a bug or a FR I could raise here to make this available? Is my only option here to re-invent the wheel and craft my own template code to display these buttons? Many thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Check out my netbox-plugin-extensions to see how I handled that. I think ultimately the goal is to make the helper function plugin safe, but that likely won't be until 3.1 |
Beta Was this translation helpful? Give feedback.
Check out my netbox-plugin-extensions to see how I handled that.
I think ultimately the goal is to make the helper function plugin safe, but that likely won't be until 3.1