Unable to use Generic Views with Plugins #3657

Closed
opened 2025-12-29 18:30:24 +01:00 by adam · 4 comments
Owner

Originally created by @jtopjian on GitHub (May 7, 2020).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.8.1

Steps to Reproduce

  1. Download, install, and enable the netbox-animal-sounds plugin.

  2. Visit https://netbox.example.com/plugins/animal-sounds and confirm functionality.

  3. Modify the ListAnimalsView to look like:

class ListAnimalsView(ObjectListView):
    queryset = Animal.objects.all()
    table = AnimalTable
  1. Create a table that looks like:
class AnimalTable(BaseTable):
    class Meta(BaseTable.Meta):
        model = Animal
        fields = ('name',)
  1. Visit https://netbox.example.com/plugins/animal-sounds

Expected Behavior

A generic view would be rendered.

Observed Behavior

I received the following error:

NoReverseMatch at /plugins/animal-sounds/
Reverse for 'None' not found. 'None' is not a valid view function or pattern name.

After digging around, this is related to the add_button function (as well as the import_button function, etc). They are unable to determine the reverse URL of the plugin views. By changing the view to this:

class ListAnimalsView(ObjectListView):
    queryset = Animal.objects.all()
    table = AnimalTable
    action_buttons = ()

The page renders, but it's not very useful.

Originally created by @jtopjian on GitHub (May 7, 2020). ### Environment * Python version: 3.6.9 * NetBox version: 2.8.1 ### Steps to Reproduce 1. Download, install, and enable the [netbox-animal-sounds](https://github.com/netbox-community/netbox-animal-sounds) plugin. 2. Visit https://netbox.example.com/plugins/animal-sounds and confirm functionality. 3. Modify the `ListAnimalsView` to look like: ```python class ListAnimalsView(ObjectListView): queryset = Animal.objects.all() table = AnimalTable ``` 4. Create a table that looks like: ```python class AnimalTable(BaseTable): class Meta(BaseTable.Meta): model = Animal fields = ('name',) ``` 5. Visit https://netbox.example.com/plugins/animal-sounds ### Expected Behavior A generic view would be rendered. ### Observed Behavior I received the following error: ``` NoReverseMatch at /plugins/animal-sounds/ Reverse for 'None' not found. 'None' is not a valid view function or pattern name. ``` After digging around, this is related to the `add_button` function (as well as the `import_button` function, etc). They are unable to determine the reverse URL of the plugin views. By changing the view to this: ``` class ListAnimalsView(ObjectListView): queryset = Animal.objects.all() table = AnimalTable action_buttons = () ``` The page renders, but it's not very useful.
adam closed this issue 2025-12-29 18:30:24 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 7, 2020):

The NetBox views and tables are not provided as part of the plugins API (the extent of which is documented here). They are for internal use only and subject to change at any time. Plugin authors are responsible for writing their own views.

@jeremystretch commented on GitHub (May 7, 2020): The NetBox views and tables are not provided as part of the plugins API (the extent of which is documented [here](https://netbox.readthedocs.io/en/stable/plugins/development/)). They are for internal use only and subject to change at any time. Plugin authors are responsible for [writing their own views](https://docs.djangoproject.com/en/3.0/topics/http/views/).
Author
Owner

@jtopjian commented on GitHub (May 7, 2020):

Thank you for replying so quickly.

the extent of which is documented here

If you're talking about the document that describes plugin limitations, I think you mean this one:

https://netbox.readthedocs.io/en/stable/plugins/

However, I read both over numerous times, and while it's totally possible that I misread something, I don't believe it mentioned that I could not take advantage of Netbox's pre-built views. I'm not trying to override them. I'm simply trying to use existing code which has proven to work with Netbox already.

Maybe it's just me, but it only seemed logical that I would look at the numerous existing Netbox models, views, tables, forms, etc as the right way to create a functional Netbox-based plugin 🤷‍♂️

I see that you've gone through a good amount of trouble to make writing plugins easy -- and that's appreciated. For example, hooking into the navigation system is an awesome way of not having to fiddle with overriding templates just to get your plugin on a menu. But being able to leverage the existing Netbox views would be an awesome way to further lower the barrier to plugins.

@jtopjian commented on GitHub (May 7, 2020): Thank you for replying so quickly. > the extent of which is documented here If you're talking about the document that describes plugin limitations, I think you mean this one: https://netbox.readthedocs.io/en/stable/plugins/ However, I read both over numerous times, and while it's totally possible that I misread something, I don't believe it mentioned that I could not take advantage of Netbox's pre-built views. I'm not trying to override them. I'm simply trying to use existing code which has proven to work with Netbox already. Maybe it's just me, but it only seemed logical that I would look at the numerous existing Netbox models, views, tables, forms, etc as the right way to create a functional Netbox-based plugin 🤷‍♂️ I see that you've gone through a good amount of trouble to make writing plugins easy -- and that's appreciated. For example, hooking into the navigation system is an awesome way of not having to fiddle with overriding templates just to get your plugin on a menu. But being able to leverage the existing Netbox views would be an awesome way to further lower the barrier to plugins.
Author
Owner

@jeremystretch commented on GitHub (May 7, 2020):

I think you mean this one

I meant the page I linked to. That document describes all the integrations available for the development of plugins.

I don't believe it mentioned that I could not take advantage of Netbox's pre-built views

The plugins API specifies only what is supported, not what is not supported. If it's not mentioned in the framework documentation, it's not supported.

@jeremystretch commented on GitHub (May 7, 2020): > I think you mean this one I meant the page I linked to. That document describes all the integrations available for the development of plugins. > I don't believe it mentioned that I could not take advantage of Netbox's pre-built views The plugins API specifies only what *is* supported, not what is *not* supported. If it's not mentioned in the framework documentation, it's not supported.
Author
Owner

@jtopjian commented on GitHub (May 7, 2020):

I'm not sure if you are intending for this, but I feel like your replies are confrontational. I'm not trying to argue with you. I reported an issue, and based on your first terse reply felt I had to justify why I reported the issue in the first place.

I now understand that using core netbox views is not supported and that this is a design decision of netbox. That's fine - I'll live with that.

I apologize for not understanding that and will do better next time to know that anything that is not documented is not supported.

@jtopjian commented on GitHub (May 7, 2020): I'm not sure if you are intending for this, but I feel like your replies are confrontational. I'm not trying to argue with you. I reported an issue, and based on your first terse reply felt I had to justify why I reported the issue in the first place. I now understand that using core netbox views is not supported and that this is a design decision of netbox. That's fine - I'll live with that. I apologize for not understanding that and will do better next time to know that anything that is not documented is not supported.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3657