Hi all,
I have a problem with the extra() method of queryset.
So, i retrieve my objects with :
invoices = Invoice.objects.select_related().filter(quantity__gt=0,begin__gte=values['start_day'],end__lte=values['end_day'])
So it works, I have my invoices. After i use another time filter() :
invoices = invoices.filter(max__gte=duration)
It works too. But, after, i need to use extra() because of my request, so i have that :
cond = 'discount="YES" AND priceeuro*(%d%%fixe)<=%d'
invoices = invoices.extra(where=[cond],params=[duration,price])
Well, it works but my invoices variable contains more elements that before. It's like the two filter() weren't used.
If you know why,
thanks.
EDIT:
This is the SQL associated with the query:
WHERE
("invoice"."product_id" IN (
SELECT U0."id"
FROM "product" U0
WHERE U0."accommodation_id" IN (
SELECT U0."id"
FROM "accommodation" U0
WHERE U0."resort_id" IN (
SELECT U0."id"
FROM "resort" U0
WHERE U0."area_id" IN (
SELECT U0."id"
FROM "area" U0
WHERE U0."country_id" = 9
))))
AND "invoice"."quantity" > 0
AND "invoice"."end" <= 2010-12-31
AND "invoice"."begin" >= 2010-12-01
AND fixe % 7 = 0
AND (discount="YES" AND pricediscountincludedeuro*(7% fixe)<=250)OR(discount="NO" AND priceeuro*(7% fixe)<=250))