Make NetBox views not dependent on NetBox models and RestrictedQuerySet #8156

Closed
opened 2025-12-29 20:33:10 +01:00 by adam · 3 comments
Owner

Originally created by @arthanson on GitHub (Jun 1, 2023).

Originally assigned to: @arthanson on GitHub.

Proposed Changes

Currently if you use generic.ObjectListView (and probably the bulk edit views) there are assumptions in the view code that the models are derived from NetBox models and using the RestrictedQuerySet. See: https://github.com/netbox-community/netbox/blob/develop/netbox/utilities/views.py#L82

Justification

This change would allow any model to use ObjectListView and the other bulk import views. This issue was a blocker for moving the User and Group admin into NetBox as those models are not derived from NetBox models.

Originally created by @arthanson on GitHub (Jun 1, 2023). Originally assigned to: @arthanson on GitHub. ### Proposed Changes Currently if you use generic.ObjectListView (and probably the bulk edit views) there are assumptions in the view code that the models are derived from NetBox models and using the RestrictedQuerySet. See: https://github.com/netbox-community/netbox/blob/develop/netbox/utilities/views.py#L82 ### Justification This change would allow any model to use ObjectListView and the other bulk import views. This issue was a blocker for moving the User and Group admin into NetBox as those models are not derived from NetBox models.
adam added the type: housekeeping label 2025-12-29 20:33:10 +01:00
adam closed this issue 2025-12-29 20:33:10 +01:00
Author
Owner

@DanSheps commented on GitHub (Jun 2, 2023):

@arthanson

Can you not use a proxy model to handle this or could we not use just a regular views.View? I think the whole point of "ObjectView" "ObjectListView" is that they are tied to an Object (Model) so removing this sort of defeats the purpose of the view itself.

I think a BaseView/BaseListView might be nice, but I don't think we should go mucking with the ObjectListView/ObjectView directly as they are also directly usable by plugins.

@DanSheps commented on GitHub (Jun 2, 2023): @arthanson Can you not use a proxy model to handle this or could we not use just a regular views.View? I think the whole point of "ObjectView" "ObjectListView" is that they are tied to an Object (Model) so removing this sort of defeats the purpose of the view itself. I think a BaseView/BaseListView might be nice, but I don't think we should go mucking with the ObjectListView/ObjectView directly as they are also directly usable by plugins.
Author
Owner

@abhi1693 commented on GitHub (Jun 2, 2023):

Here is an implementation that I did one weekend, if you want to refer: https://github.com/Onemind-Services-LLC/netbox-users/tree/dev

@abhi1693 commented on GitHub (Jun 2, 2023): Here is an implementation that I did one weekend, if you want to refer: https://github.com/Onemind-Services-LLC/netbox-users/tree/dev
Author
Owner

@arthanson commented on GitHub (Jun 14, 2023):

closing, it turned out to be a one-line change incorporating into the PRs for moving admin functionality into NetBox

@arthanson commented on GitHub (Jun 14, 2023): closing, it turned out to be a one-line change incorporating into the PRs for moving admin functionality into NetBox
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8156