Replace FeatureQuery with a custom manager method for ContentType #14153
Labels
status: accepted
This issue has been accepted for implementation
type: housekeeping
Changes to the application which do not directly impact the end user
Milestone
Proposed Changes
NetBox uses the FeatureQuery class to filter ContentType querysets by support for a specific feature. For example, to retrieve the content types corresponding to all models which support the assignment of jobs:
This proposal is to move this logic to a custom manager method for ContentType, such that we could instead do:
In addressing #13427, PR #14152 proposes introduce a proxy model and custom manager for ContentType, which would be easily extended to support this implementation.
Justification
FeatureQuery has always felt cumbersome to use, and is not invoked consistently for all use cases (i.e. sometimes
get_query()
is needed and sometimes not). The proposed approach provides a much cleaner mechanism for filtering ContentTypes by supported feature.The text was updated successfully, but these errors were encountered: