Suggestion to change the Logger date format to ISO 8601

2019-12-16 Thread Leon Albrecht
At the moment Django is using "DD/MMM/ hh:mm:ss", but since 1988 there 
exists an ISO to format dates like this: "YYY-DD-MM hh:mm:ss"

this is not a majot change and i've searched for to do it myself but 
according to the python logger libary this format is already in use, but 
Django apperantly changes it, somewhere I could not find it, to the 
beforementioned format.

-- 
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/9536ce2f-e864-4231-99b5-66a7fde9f77c%40googlegroups.com.


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 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-developers+unsubscr...@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.


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 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  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.


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__icontains=query) |
Q(author__last_name__icontains=query) |
Q(title__icontains=query) |
Q(year=int(query) if query.isdigit() else -1)
)
books = Book.obejects.filter(complete_query).distinct() # the 
distinct is for the issue described in the PPS

... # render page with the filtered books


in the Example the searchquery is a string of features seperated by 
whitespaces the user wants to search for and the Book model is similar to 
the one described in the django tutorials, if I remember them right.

-- 
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/4ee7d03e-3c19-4fab-bf8b-4624fbdb9da5n%40googlegroups.com.