Skip to content
New issue

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

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

Already on GitHub? # to your account

Filter with URL /?date__isnull=true is not working. #1701

Open
Natgho opened this issue Jan 30, 2025 · 3 comments
Open

Filter with URL /?date__isnull=true is not working. #1701

Natgho opened this issue Jan 30, 2025 · 3 comments

Comments

@Natgho
Copy link

Natgho commented Jan 30, 2025

Filter with URL /?date__isnull=true is not working.

I created the modelviewset;

class ABC(Model):
    closed_at= models.DateTimeField()
class ABC(viewsets.ModelViewSet):
    serializer_class = ABCSerializer
    queryset = ABC.objects.all()
    filter_backends = [DjangoFilterBackend]

and send to request for filtering;
/?sample_other_filter=83&closed_at__isnull=true

and I saw the queryset is not adding "null check", after when I created to FilterSet manually, it is worked. But it seems, default filter generation is not working properly for DateTimeField.

@carltongibson
Copy link
Owner

@Natgho
Copy link
Author

Natgho commented Jan 30, 2025

Yes, but why not include these filters by default? __isnull, __gt etc. ?

@carltongibson
Copy link
Owner

Every filter added expands the surface area of the API, it's a balance.

This isn't a change I'm going to make.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants