Closed ppython closed 8 years ago
Thanks for the pull request!
This sounds like something that can be trivially implemented in your own code, without requiring a change to django-watson. What advantage is there in adding this parameter to django-watson?
Sure,
Some exemples, the first one being the one for my case:
Now, I could have my own django-watson custom SearchEngine
Class and override it's search
method to achieve what I need; or might even not use watson and pass by Django ORM directly (or in the same override as well, wich would simplifies the code on the search end) with it's filters;
I needed a start in achieving this 'blank query' thing and thought this would be one more little thing watson could achieve :)
I think you can do this much more simply in your own code:
if query == "":
return SearchEntry.objects.all()
else:
return watson.search(query)
Given how simple the logic is, I struggle to see the benefit of adding it to django-watson.
Exact, this simple case make the modification to the package useless :)
Just to add if someones stumble upon this; If we want to do it per model:
from django.contrib.contenttypes.models import ContentType
SearchEntry.objects.filter(content_type=ContentType.objects.get_for_model(Your_model))
I'll close this PR, thanks for the discussion anyway!
Cool, this will be nice documentation if anyone else has the same issue. Thanks, Google! :P
Happy coding! 😄
I need to be able to return all results even if the query is blank.
This patch adds an optional bool parameter 'blank_search_results' to search(). When set to True, it will return all the objects.
Ex. of usage: