Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean filters don't work as expected #25

Closed
karmux opened this issue Jun 16, 2015 · 3 comments
Closed

Boolean filters don't work as expected #25

karmux opened this issue Jun 16, 2015 · 3 comments

Comments

@karmux
Copy link
Contributor

karmux commented Jun 16, 2015

Django REST Framework says that When using boolean fields, you should use the values True and False in the URL query parameters, rather than 0, 1, true or false.

This cannot be achieved with django-rest-framework-filters. Must use 0 or 1 for boolean field filtering. True and False doesn't work.

@rpkilby
Copy link
Collaborator

rpkilby commented Oct 18, 2015

Hi @karmux. Can you include an example FilterSet and model?

@karmux
Copy link
Contributor Author

karmux commented Oct 26, 2015

@rpkilby ,

class Stuff(models.Model):
    is_active = models.BooleanField()
    ...


class StuffFilter(filters.FilterSet):
    is_active = filters.AllLookupsFilter(name='is_active')

    class Meta:
        model = Stuff


class StuffViewSet(viewsets.ModelViewSet):
    serializer_class = StuffSerializer
    queryset = Stuff.objects.all()
    filter_class = StuffFilter

Must use ?is_active=0 or ?is_active=1. Using false, False, true or True doesn't work.

@rpkilby
Copy link
Collaborator

rpkilby commented Nov 21, 2015

Thanks @karmux, I'll start working on a test case.

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

No branches or pull requests

2 participants