Re: select_related() and null=True

2007-03-06 Thread noelbk
I just created a python module to solve this problem for myself. It's let's you write SQL that returns Django objects. For your problem, you could do something like this: for ticket in DjSelect(""" from {Ticket:ticket} left join {User:ticket.resolved_by} on {ticket.resolved_by}.id =

Re: select_related() and null=True

2007-03-06 Thread Ivan Sagalaev
Ilya Semenov wrote: > What different approach could I choose? I'm writing real-life model - > a Ticket can either have a User (who resolved it), or not (if the > ticket has not been yet resolved). Listing all resolved Tickets with > corresponding Users is a simple real-life task, too. Indeed... H

Re: select_related() and null=True

2007-03-06 Thread Ilya Semenov
David Cramer wrote: > but I strongly encourage you to find a > differently solution, as LEFT JOINs can be VERY costly on system > resources. I realize that under some circumstances, LEFT JOINs can be costly. However, I don't hink my case is such. Let me recall the (I believe very simple) model:

Re: select_related() and null=True

2007-03-05 Thread David Cramer
The problem with this is, when the foreignkey can be null the only way to reference it properly is with a LEFT JOIN. Now, I'm not sure why it isnt implemented in ORM, but I strongly encourage you to find a differently solution, as LEFT JOINs can be VERY costly on system resources. On the same not

select_related() and null=True

2007-03-05 Thread Ilya Semenov
Hello everyone, I've run into the problem which I believe is a common use-case and is already solved, but I can't seem to find the answer neither in documentation, nor in django-users or django-developers. Here it goes: how do I optimize a list query if I have null=True foreign key in my entity?