Thanks everyone.
Now I have got a clear idea of how these both statements differ to each
other.
Thanks and Regards,
Mahendra
On Tue, Apr 4, 2017 at 5:55 PM, Todor Velichkov
wrote:
> I didn't use anything special, just print on queryset.query
>
> qs1 = Blog.objects.filter(entry__headline__co
f Of Todor Velichkov
Sent: Monday, April 3, 2017 3:06 PM
To: Django users
Subject: Re: filter chaining v/s filter with multiple arguments.
Nope, they are not the same.
The first one:
Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__year=2008)
Will produce the
I didn't use anything special, just print on queryset.query
qs1 = Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__year=2008)
qs2 = Blog.objects.filter(entry__headline__contains='Lennon').filter(
entry__pub_date__year=2008)
print qs1.query
print qs2.query
On Tuesday, Ap
Thanks Todor Velichkov.
It would be great if you let me know how did you get these queries (tool
name etc).
Because when I was trying to get MySQL query using *q.query*, these both
statements were giving same query.
Thanks and Regards,
Mahendra
On Tue, Apr 4, 2017 at 1:35 AM, Todor Velichkov
Nope, they are not the same.
The first one:
Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__year=2008)
Will produce the following SQL:
SELECT
"blog_blog"."id",
"blog_blog"."name",
"blog_blog"."tagline"
FROM
"blog_blog"
INNER JOIN "blog_entry" ON ("bl
this helps.
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of Mahendra Gaur
Sent: Monday, April 3, 2017 9:42 AM
To: django-users@googlegroups.com
Subject: RE: filter chaining v/s filter with multiple arguments.
Thanks for reply.
I have tried q.query on both statements
Thanks for reply.
I have tried q.query on both statements but both are giving same query. I
had tried this even before initiating this mail chain, and this was the
point where I got confused.
Thanks and regards,
Mahendra Gaur
On 3 Apr 2017 6:55 p.m., "Matthew Pava" wrote:
Hi Mahendra,
You
Hi Mahendra,
You can view the SQL that is generated by using the query attribute on the
QuerySet.
q = Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__year=2008)
print(str(q.query))
That should help in understanding what is going on.
Best wishes!
From: django-users@goo
Thank you for reply.
In case of second statement, why two JOIN are required each with single
filter ?
As per my understanding whether it use one JOIN with both the filter or two
JOIN each with single filter, both are same.
correct me if am wrong ?
Thanks and Regards,
Mahendra
On Mon, Apr 3, 20
The first one will use a single JOIN on the entry table, and will apply
both filters to that table.
The second one will JOIN the entry table twice, and for every join will
apply only a single filter
On Sunday, April 2, 2017 at 5:41:29 PM UTC+3, Mahendra Gaur wrote:
>
> Hello everyone,
>
> I am n
10 matches
Mail list logo