Replies: 1 comment 1 reply
-
I believe #14732 is the PR you're looking for. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When building plugins sometimes you want to enhance the experience for users that create base models to directly create relationships to plugin models. It is currently possible using custom fields together with plugins but that is not an optimal solution due to connecting plugin logic to custom fields that the users themselves could delete or change.
I am building a plugin where I would like to enhance the experience for users so that they could directly create relationships to plugin models when creating a base model. For example creating a prefix and directly connecting it to a plugin model. The relationship is today possible to do in reverse where I can connect the prefix to a plugin model but that would in turn create two interactions, one with creating the base model and one with creating or updating the plugin model to include the base model as a relationship.
Obviously using plugin models and relationships from that direction is more declarative and exposes functionality the database can perform with cascading and so on that would not be possible when using json-data. But maybe some wrapper functionality could recreate some of that behavior if needed.
My suggestion is reusing custom fields data or creating a new field for custom plugin data that plugin creators could plug into that enhances base models without interfering with the base model.
I know the basis for plugins is not to mess with base models but I see potential using the same approach as custom fields with json-data and translating django-queries like custom_fields_data does today.
My example where DHCP Servers is a custom field that point to my plugin model DHCP Servers.
This is editing a prefix and adding a dhcp server using a custom field.
This is my plugin model servers that displays all connected prefixes.
The query that gets all connected prefixes with this server id.
It would be very nice if NetBox exposes some of this behavior that is possible with custom field data but for a plugin.
I have tried researching if someone else have done this kind of solution before but I cannot find anything. Anyone that have a similar problem and have resolved it somehow?
Beta Was this translation helpful? Give feedback.
All reactions