Skip to content

Support for Query Parameters in Filters Without Corresponding Model Fields #1431

@tomdtp

Description

@tomdtp

Problem

When using custom filters that perform search across multiple fields (e.g., a search parameter that queries several fields but doesn’t correspond directly to a single model field), drf-spectacular raises warnings during schema generation:

Warning: Exception raised while trying resolve model field for django-filter field "search". Defaulting to string (Exception: 'search')

Currently, there is no built-in way to explicitly tell drf-spectacular that a filter parameter is not tied to a specific model field, but rather a virtual or multi-field search. This results in noisy warnings or inaccurate schema generation.

Request

Add a supported mechanism or option in drf-spectacular to declare that a filter parameter is a “virtual” or “multi-field” search, allowing:

  • Suppression of misleading warnings.
  • Correct schema documentation of the parameter.
  • Better integration with custom filter backends like multi-field or translated search filters.

This would greatly improve usability for projects implementing complex search filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions