Last active
February 22, 2018 07:44
-
-
Save filipgorczynski/84e8438972582e355e95e89f7a340c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorldViewSet(viewsets.ModelViewSet) | |
def get_queryset(self): | |
qs = super().get_queryset() | |
# Dobieramy się do parametrów żądania | |
query = self.request.query_params.get('q') | |
stripped_query = query.strip() if isinstance(query, str) else None | |
if stripped_query == '': | |
# Interesująca nas linijka | |
return qs.none() | |
# dodatkowe filtry, pomijane gdy stripped_query będzie None | |
# otrzymamy wszystkie wyniki bez filtrowania | |
if stripped_query: | |
# qs = qs.filter() | |
... | |
return qs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment