OK no clue, why it didn't send my answer from 15min ago but, I will give an example similar to my exact use case:
... search_query = request.GET.get("q", "").lower() # string of features the user searches for separated by whitespaces complete_query = ~Q(pk__in=[]) # this should be something like Q.ident() for query in search_query.split(): complete_query &= ( Q(author__first_name__icontains = query) | Q(author__last_name__icontains = query) | Q(year = query if query.isdigit() else -1) | Q(title__icontains = query) ) books= Book.objects.filter(complete_query).distinct() # distinct() is fo rthe issue described in the PPS ... # render page with relevant books ---- Leon PS: Does this service allow inline html, could have been the reason why it wasn't send or it just takes a while and I'm to imaptient Adam Johnson schrieb am Sonntag, 20. Dezember 2020 um 18:33:07 UTC+1: > How is this different from QuerySet.all() ? Can you give a code example of > what you'd imagine this API doing? > > On Sun, 20 Dec 2020 at 17:05, Leon Albrecht <leon2...@gmail.com> wrote: > >> Hey everyone, >> >> I'm running a website, that uses a search bar, and to parse said search >> bar, I "and" together multiple queries in a loop, >> but to start of I need a Identity-Query, that does nothing and return >> everything. >> There are solutions to create one, but they aren't free and do not look >> good or intuitive. >> >> So I suggest adding a Identity-Query object, which gets discarded by the >> optimizer during the SQL generation stage. >> >> Leon >> >> PS: >> Just using multiple filters wont work, because they always use the >> original data set and unify all results at the end. >> >> PPS: >> An issue that occurred me is that "and"-ing together queries may cause >> the results to be duplicate. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers (Contributions to Django itself)" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-develop...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-developers/65ce7659-9101-4d60-89be-28b076f97f13n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-developers/65ce7659-9101-4d60-89be-28b076f97f13n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Adam > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/e8fc4d38-e57d-4177-9723-59377e254380n%40googlegroups.com.