-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add support for custom fields in tables #5460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom fields in tables #5460
Conversation
|
Works nicely 👍 I applied this patch on v2.10.1 and just tested a bit. I will continue using this patch and see if anything breaks. Edit: It is only a front end change, no database migration or something. So I feel safe running this patch and will take responsibility if something breaks. |
|
On v2.10.2 is also working has expected. Thanks for this feature. |
|
@ypid @ecoutinho Keep in mind we will not support you deploying this to your current instances and you will be responsible for resolving any issues you encounter yourself. |
|
I just tested on the docker instance (v2.10.3) - working fine for me right now, so thanks. |
|
@TomGrozev Can you adress the issues raised by @ecraven and @ixinshang? I think we are not too far off. |
A quick fix: (venv) rodrigo@ufsclinux:~/CGR/netbox/netbox$ git diff
diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py
index 4a796435..cd5af482 100644
--- a/netbox/utilities/tables.py
+++ b/netbox/utilities/tables.py
@@ -33,7 +33,7 @@ class BaseTable(tables.Table):
label = cf.label if cf.label != '' else cf.name
self.base_columns[name] = CustomFieldColumn(verbose_name=label)
custom_fields[name] = cf
- self._meta.fields += tuple(custom_fields.keys())
+ self._meta.fields += tuple(x for x in custom_fields.keys() if x not in self._meta.fields)
# Init table
super().__init__(*args, **kwargs) |
@keitarobr hi,i changed code in tables.py in 36 line. thanks all. |
|
Thanks @TomGrozev. Merging this into a local branch to wrap it up for v2.11. |
This change adds custom fields to tables based on the work of [TomGrozev](https://github.com/TomGrozev) and [keitarobr](https://github.com/keitarobr) in netbox-community/netbox#5460 (already merged). Co-authored-by: Glenn Matthews <[email protected]>

Fixes: #5344
This adds support for having custom fields in list view tables. All changes are make in the BaseTable class to prevent changing on every table object. Since the custom fields are JSON, if the value is a list they will be displayed as labels.
The mentioned issue is marked blocked but this should be removed since the release of 2.10.