Skip to content

ModelChoiceFilter.to_field_name are not respected in contrib.django_filters #1443

@matwey

Description

@matwey

Describe the bug
When django filter is constructed by means of ModelChoiceFitler as following:

foo = filters.ModelChoiceFilter(queryset=models.Foo.objects.all(), to_field_name="name")

schema is incorrectly has type of int instead of usually expected string.

To Reproduce
See the snipped above.

Expected behavior
DjangoFilterExtension should introspect to_field_name argument if it exists for ModelChoiceFilter object while automatically discovers the schema.

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