netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.36k stars 2.6k forks source link

Clarify requirements for module and class naming #15967

Open peteeckel opened 6 months ago

peteeckel commented 6 months ago

Change Type

Addition

Area

Plugins

Proposed Changes

I'd like to suggest adding a clarification to the NetBox plugin developer documentation, specifically the section about filtersets.

As I learned the hard way, there is a strong requirement for the filtersets of a plugin to be defined in the module filtersets, and for the filterset class for an object named, e.g. MyObject to be named MyObjectFilterSet.

While this initially isn't obvious and filtersets not following this requirement will appear to work at first, there are some issues lurking if this requirement isn't satisfied. One of the issues is that the NetBox test suite for filtersets will fail if the naming isn't exactly like described above, I found today that selectors in model select fields will fail (silently, unless error mails are enabled) in that case. There are some more issues as well.

While all examples and the plugin tutorial are compliant, an explicit mention of the strict requirement to use that naming would be useful. I've seen a couple of plugins (including the original NetBox DNS when I started working on it) that don't, so it doesn't seem to be obvious, and just today there was another help request in the netbox-plugin-development Slack channel.

peteeckel commented 6 months ago

I could add a few sentences to the description if you assign this to me.

jeremystretch commented 6 months ago

Thanks @peteeckel!