Skip to content

Object types are not filtered appropriately when filtering custom fields #11786

@jeremystretch

Description

@jeremystretch

NetBox version

v3.4.4

Python version

3.8

Steps to Reproduce

  1. View the custom fields list in the UI
  2. Select the "filters" tab
  3. Open the "object type" filter dropdown

Expected Behavior

Only relevant object types (those to which custom fields can be assigned) should be included in the list.

Observed Behavior

All known object types are listed. (This affects several other models too, in addition to custom fields.)

It appears that Django does not acknowledge limit_choices_to when set on fields on non-model forms. Apparently this has never actually been a documented kwarg for ModelChoiceField; its acceptance as a keyword argument seems to be incidental to support for the attribute on ForeignKey models fields.

We'll need to devise an alternative solution for filtering ModelChoiceFields on non-model forms (e.g. CustomFieldFilterForm).

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions