Namespace tables when referenced under DEFAULT_USER_PREFERENCES #6190

Closed
opened 2025-12-29 19:37:52 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Mar 9, 2022).

NetBox version

v3.2.0-beta2

Feature type

Change to existing functionality

Proposed functionality

NetBox v3.2 introduces the ability to define default preferences via the DEFAULT_USER_PREFERENCES configuration parameter. For example, we can set the default column visible for a table:

DEFAULT_USER_PREFERENCES = {
    'tables': {
        'SiteTable': {
            'columns': ['name', 'status', 'facility', 'region', 'tenant']
        }
    }
}

The table identifier derives from the Python class name. However, this can lead to a conflict should a plugin introduce a table with the same name: The current approach offers no way to distinguish between e.g. dcim.tables.SiteTable and myplugin.tables.SiteTable.

We should probably namespace the table by app in some way. There are a few options, but I think I would prefer to prepend the app name to the class name:

DEFAULT_USER_PREFERENCES = {
    'tables': {
        'dcim.SiteTable': {
            'columns': ['name', 'status', 'facility', 'region', 'tenant']
        }
    }
}

NetBox would check SiteTable.Meta.model._meta.app_label when instantiating the table to determine the appropriate app label.

I'm open to other suggestions as well.

Use case

Ensuring a unique reference for each table avoids potential conflicts with tables introduced by plugins.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Mar 9, 2022). ### NetBox version v3.2.0-beta2 ### Feature type Change to existing functionality ### Proposed functionality NetBox v3.2 introduces the ability to define default preferences via the `DEFAULT_USER_PREFERENCES` configuration parameter. For example, we can set the default column visible for a table: ```python DEFAULT_USER_PREFERENCES = { 'tables': { 'SiteTable': { 'columns': ['name', 'status', 'facility', 'region', 'tenant'] } } } ``` The table identifier derives from the Python class name. However, this can lead to a conflict should a plugin introduce a table with the same name: The current approach offers no way to distinguish between e.g. `dcim.tables.SiteTable` and `myplugin.tables.SiteTable`. We should probably namespace the table by app in some way. There are a few options, but I think I would prefer to prepend the app name to the class name: ```python DEFAULT_USER_PREFERENCES = { 'tables': { 'dcim.SiteTable': { 'columns': ['name', 'status', 'facility', 'region', 'tenant'] } } } ``` NetBox would check `SiteTable.Meta.model._meta.app_label` when instantiating the table to determine the appropriate app label. I'm open to other suggestions as well. ### Use case Ensuring a unique reference for each table avoids potential conflicts with tables introduced by plugins. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurestatus: under reviewbeta labels 2025-12-29 19:37:52 +01:00
adam closed this issue 2025-12-29 19:37:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 23, 2022):

As tables are already not namespaced within the user preferences hierarchy, this will need to be addressed there first.

@jeremystretch commented on GitHub (Mar 23, 2022): As tables are already not namespaced within the user preferences hierarchy, this will need to be addressed there first.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6190