Skip to content

Add slug filter to CustomObjectTypeFilterSet#527

Closed
Kani999 wants to merge 1 commit into
netboxlabs:mainfrom
Kani999:feature/cot-filterset-slug
Closed

Add slug filter to CustomObjectTypeFilterSet#527
Kani999 wants to merge 1 commit into
netboxlabs:mainfrom
Kani999:feature/cot-filterset-slug

Conversation

@Kani999
Copy link
Copy Markdown

@Kani999 Kani999 commented May 26, 2026

Summary

GET /api/plugins/custom-objects/custom-object-types/?slug=foo previously returned every Custom Object Type — django-filter silently dropped the unrecognised query parameter because CustomObjectTypeFilterSet.Meta.fields didn't include slug. Adding slug to the tuple lets django-filter auto-generate the full lookup family (exact, __ic, __isw, __regex, ...) backed by the CustomObjectType.slug SlugField.

Verification

Verified via manage.py shell:

from netbox_custom_objects.filtersets import CustomObjectTypeFilterSet
'slug' in CustomObjectTypeFilterSet.base_filters
# True

After the change, all of these now narrow the result set:

  • ?slug=vendor-policies
  • ?slug__ic=policies (icontains)
  • ?slug__isw=vendor (istartswith)

Context

Surfaced during the related-object-tabs smoke test on 2026-05-26 (PR #482).

@Kani999 Kani999 mentioned this pull request May 26, 2026
GET /api/plugins/custom-objects/custom-object-types/?slug=foo previously
returned every COT — django-filter silently dropped the unrecognised
query parameter because the filterset's Meta.fields didn't include slug.
Adding slug to the tuple lets django-filter auto-generate the full
lookup family (exact, __ic, __isw, __regex, ...) backed by the
CustomObjectType.slug SlugField.

Verified via manage.py shell:

    from netbox_custom_objects.filtersets import CustomObjectTypeFilterSet
    'slug' in CustomObjectTypeFilterSet.base_filters
    True

Side observation from PR netboxlabs#482's polymorphic smoke run on 2026-05-26.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Kani999 Kani999 force-pushed the feature/cot-filterset-slug branch from 606ed8e to 7a0412d Compare May 26, 2026 12:04
@bctiemann
Copy link
Copy Markdown
Contributor

Hi @Kani999 -- please don't open a PR unless there is an accepted bug or feature issue to link it to.

Please open a bug ticket first, then once it's triaged and accepted you can reopen this PR. Thanks!

@bctiemann bctiemann closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants