Skip to content

How to use the field 'in' in django-rest-framework-filters, like 'user_id__in=[12,13]'? #360

@weiyong996

Description

@weiyong996

My FilterSet

class UserFilter(filters.FilterSet):
    class Meta:
        model = User
        fields = {'id': ['exact', 'in',]}

Evn

python 3.7
django 2.1.1
django-filter 2.1.0
djangorestframework 3.8.2
djangorestframework-filters 1.0.0.dev2

Issue Description

I use postman send a request

I want to match to ids (for example: Bob, Alice), the logic url is: /api/companies?user_id__in=[12,13]
(I know that both '[' and ']' will be converted to %5B and %5D by browser, so true url is: /api/companies?user_id__in=%5BBob,Alice%5D)

I hope get two records by user_id__in[12,13], unfortunately I get all records, so how to resolve the problem?
Is there something wrong with me?

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy