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

strict setting being honored on DRF? #603

Closed
dbinetti opened this issue Jan 14, 2017 · 2 comments
Closed

strict setting being honored on DRF? #603

dbinetti opened this issue Jan 14, 2017 · 2 comments

Comments

@dbinetti
Copy link

I'm afraid I don't understand enough to write a proper test, but here is how to reproduce.

from django_filters import rest_framework as filters
from django_filters.filterset import STRICTNESS

from .models import Model

class ModelFilter(filters.FilterSet):
    class Meta:
        model = Model
        fields = {'title': ['icontains']}
        strict = STRICTNESS.RAISE_VALIDATION_ERROR

Then, GET /model?foo=bar. I expect a 500, but I get a 200 with all records. A GET /model?title=batbaz produces the expected result.

Thanks...

@dbinetti
Copy link
Author

Just a quick update that I was originally on version 0.15.3, and have since upgraded to 1.0.1. However, merely change the import above from from django_filters.filterset import STRICTNESS to from django_filters import STRICTNESS and you'll get the same behavior on v 1.0.1.

@carltongibson
Copy link
Owner

Yeah. This is expected behaviour. The FilterSet will only apply STRICTNESS for query parameters that it's expecting to handle, i.e. its fields.

This has to be the case: e.g. I want to add pagination, ?page=2 🔥 — you get this idea, add your own examples...

If you want this behaviour you could, say, override qs to check the self.data.keys() and raise there.

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