SearchFilter raises error when using with related field. · Issue #4302 · encode/django-rest-framework (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@grapo

Description

@grapo

Checklist

Steps to reproduce

  1. UseSearchFilter with serializer that has related field to RelatedModel
  2. Set search_fields = ('related_model__field', 'my_field')

Expected behavior

Correct filtering

Actual behavior

Raises "RelatedModel" has no field named 'my_field'

I will submit pull request that fix this error. It is caused by overwriting opts in SearchField.must_call_distinct