Fixes #366: Filter form and filterset support for boolean, select, and multiselect fields#479
Fixes #366: Filter form and filterset support for boolean, select, and multiselect fields#479
Conversation
|
@claude /review |
|
Claude finished @bctiemann's task in 1m 51s —— View job PR Review: Filter form and filterset support for boolean, select, and multiselect fields
OverviewThis PR correctly implements Issues / Observations1. Boolean filterset relies entirely on auto-generated django-filters behavior
This implicit reliance is fragile. A future django-filters version bump or change to the # in get_filterset_class() alongside the select/multiselect block
elif co_field.type == CustomFieldTypeChoices.TYPE_BOOLEAN:
attrs[co_field.name] = django_filters.BooleanFilter(field_name=co_field.name)2. Identical implementations in
3. No null-guard for choices = list(co_field.choice_set.choices)If a if co_field.choice_set is None:
continue
choices = list(co_field.choice_set.choices)4. The 5. Missing widget type assertion in select/multiselect form field tests
Positives
SummaryThe implementation is correct and the test coverage is solid. The main actionable item worth addressing before merge is item 1 (implicit boolean filter behavior) — it works today but is inconsistent with the explicit approach taken for select/multiselect and could silently regress. Items 2–5 are minor. |
…, and multiselect fields - BooleanFieldType.get_filterform_field() returns NullBooleanField with yes/no Select widget - SelectFieldType.get_filterform_field() returns DynamicMultipleChoiceField backed by choice set API - MultiSelectFieldType.get_filterform_field() returns DynamicMultipleChoiceField backed by choice set API - get_filterset_class() adds MultipleChoiceFilter for select fields (OR/field__in semantics) - get_filterset_class() adds custom OR-of-__contains filter for multiselect (ArrayField) fields - Tests covering form field shape and filterset queryset filtering for all three types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2c37a52 to
8ec83d1
Compare
NetBoxModelFilterSet adds a built-in 'tag' filter that generates a tags__slug additional lookup. Naming the test multiselect field 'tags' caused get_additional_lookups() to try resolving tags__slug on our ArrayField, raising ValueError. Renaming to 'labels' avoids the clash. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Item 1 is fixed. |
Summary
Closes #366.
Test plan
🤖 Generated with Claude Code