Look up expressions on Custom Fields

459 views
Skip to first unread message

darcy...@gmail.com

unread,
Jun 24, 2021, 12:56:44 AM6/24/21
to NetBox
Hi All,

Trying to get lookup expressions to work for custom fields as per feature request 4121.
https://github.com/netbox-community/netbox/issues/4121

Something like the following works if its a base filter, but not having luck with our custom fields.

Brian Candler

unread,
Jun 24, 2021, 3:12:51 AM6/24/21
to NetBox
Netbox 2.10 reorganised custom fields into a simple JSON database field called "custom_field_data".  I don't know if it can be directly used in a view filter in the way that you want.

You ought to be able to write a report which does this.  There are a couple of samples here and here, and although those examples don't use custom field data as part of the django filter, it should be possible (since postgres supports filtering on JSON fields).  Note that "obj.cf" in Netbox 2.10+ is just an alias for "obj.custom_field_data" - see here.

Unfortunately, I don't think reports can be parameterized, in the way that custom scripts are.  That would be a nice feature.
Reply all
Reply to author
Forward
0 new messages