karatekas = Karateka.objects.extra(where = ["bsc = 1 OR skr =
1"]).select_related()
This statement runs in a loop an no data will come back.
If I change the little word "OR" to "AND",
karatekas = Karateka.objects.extra(where = ["bsc = 1 AND skr =
1"]).select_related()
the right data will show up.
Why does it not work with "OR"?
What do you mean by 'runs in a loop'? I can't parse that sentence.
What is the actual behaviour? Do you get an error?
I'm not sure why you're doing this in SQL, anyway. This can be done
directly in the ORM:
Karateka.objects.filter(Q(bsc=1) | Q(skr=1)).select_related()
--
DR.
On 4 Feb., 11:48, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Feb 4, 6:23 am, äL <lamberto.gri...@gmail.com> wrote:
>
> > I have an SQL statement in views.py:
>
> > karatekas = Karateka.objects.extra(where = ["bsc = 1 OR skr =
> > 1"]).select_related()
>
> > This statement runs in a loop an no data will come back.
>
> > If I change the little word "OR" to "AND",
>
> > karatekas = Karateka.objects.extra(where = ["bsc = 1 AND skr =
> > 1"]).select_related()
>
> > the right data will show up.
>
> > Why does it not work with "OR"?
>
> What do you mean by 'runs in a loop'? I can't parse that sentence.
> What is the actual behaviour? Do you get an error?
The browser seems to load and load an load. But no data will come up.
No, I don't get any error.
>
> I'm not sure why you're doing this in SQL, anyway. This can be done
> directly in the ORM:
> Karateka.objects.filter(Q(bsc=1) | Q(skr=1)).select_related()
I tried with your example. Now it works how I want it. Thanks a lot
for your help.