Hi all,
Please I have a question, couldn't find any answer for it..
Let's say I have 2 QuerySets:
1) Select all records from table
2) Select all records from table where color = "blue"
So QuerySet #2 is more restricted than QuerySet #1
So question is - if I get a model object from QueryS
Tom,
Could you clarify "fits into"?
qs1 = Table.objects.all()
qs2 = Table.objects.filter(color='blue')
mo1 = qs1[0]
Are you trying to determine if mo1 is in qs2?
Best
On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>
> Hi all,
> Please I have a question, couldn't find a
You can create query as
def get_query(value=None):
if value:
query = “select all records from table where color = ‘" + value + “‘
query = “select all records from table”
return query
Sent from my iPhone
> On Mar 15, 2019, at 6:20 AM, jgib...@caktusgroup.com wrote:
>
Hello,
Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the
database, if possible.
Thanks!
Tom
On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com wrote:
>
> Tom,
>
> Could you clarify "fits into"?
>
> qs1 = Table.objects.all()
> qs2 = Table.objects.filter(
Hi,
Note that Django querysets are lazy.
So running:
qs1 = MyModel.objects.all()
As is, doing that doesn't execute any queries. If you want filtered
objects, just add filter:
qs2 = qs1.filter(color="blue")
qs2 is not even evaluated yet. You need actually cause something that
evaluates queryse
result = qs1.difference(qs2)
if Result is length 0 then all of 1 is in 2.
On Monday, March 18, 2019 at 8:15:19 AM UTC-4, Thomas Klopf wrote:
>
> Hello,
> Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the
> database, if possible.
>
> Thanks!
> Tom
>
>
> On Friday, March 15,
6 matches
Mail list logo