Re: Query identity operation

2020-12-21 Thread Adam Johnson
1. Sure, pushed a commit 2. Tests: https://github.com/adamchainz/django/blob/72ce349bb283910b8c4d6a6e0f2250055b5bffb5/tests/queries/test_q.py#L6-L9 Please leave PR-specific feedback on GitHub in future :) On Mon, 21 Dec 2020 at 15:29, Ken Whitesell wrote: > A couple questions came to mind if we

Re: Query identity operation

2020-12-21 Thread Ken Whitesell
A couple questions came to mind if we're going to document this as "official behavior": 1. This also appears to be true for filter. Would the same clarification be appropriate there? 2. I don't see any tests validating the behavior for either Q or filter, should there be? Ken On 12/21/20

Re: Query identity operation

2020-12-21 Thread Adam Johnson
I saw that Q() with no arguments is not documented, so I've made a PR to add a sentence covering it: https://github.com/django/django/pull/13798 . On Mon, 21 Dec 2020 at 05:21, Mariusz Felisiak wrote: > > complete_query = ~Q(pk__in=[]) # this should be something like Q.ident() >> > > You can us

Re: Query identity operation

2020-12-20 Thread Mariusz Felisiak
> complete_query = ~Q(pk__in=[]) # this should be something like Q.ident() > You can use `complete_query = Q()`. Also, this mailing list is for discussing the development of Django itself, not for support using Django. Best, Mariusz -- You received this message because you are subscribed

Re: Query identity operation

2020-12-20 Thread Leon Albrecht
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

Re: Query identity operation

2020-12-20 Thread Leon Albrecht
Ok, I will follow with exemplary code similar to the one i use: ... searchquery = request.GET["q"] complete_query = ~Q(pk__in=[]) # this should be something like Q.ident() for query in search_query.split(): complete_query &= ( Q(autor__first_name__i

Re: Query identity operation

2020-12-20 Thread Adam Johnson
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 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

Query identity operation

2020-12-20 Thread Leon Albrecht
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