Typically I simply want to do a left join but have it as an object in
django rather than a sql raw query.

The queryset would look like.

Select
    a.code as 'product_code',
    a.description as 'product_description',
    b.code as 'customer_code',
    b.code as 'customer_description',
    ifnull(b.code, a.code) as 'code',
    ifnull(b.description, b.description) as 'description'
from
    products a
    left join customerproduct b on b.product_id = a.id where
b.customer_id = 'X'

I know I could create a view in sql and create a model for that but I
am sure there must be a nicer solution.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to