Re: Foreign Key query question

2009-04-11 Thread nikita kozlovsky
On Apr 11, 12:32 pm, Malcolm Tredinnick wrote: > That's definitely a small bug, then. I've opened ticket #10790 so that > it gets fixed eventually. Since it's not a functionality bug (the answer > is still correct), it will be fixed after 1.1 now, but we will fix it.

Re: Foreign Key query question

2009-04-11 Thread Malcolm Tredinnick
On Sat, 2009-04-11 at 01:02 -0700, nikita kozlovsky wrote: > On Apr 11, 3:11 am, Malcolm Tredinnick > wrote: > > > > Django's SQL is going exactly what you suspect and not using any outer > > join here. Using a simplified version of the original two models: > > > >

Re: Foreign Key query question

2009-04-11 Thread nikita kozlovsky
On Apr 11, 3:11 am, Malcolm Tredinnick wrote: > Django's SQL is going exactly what you suspect and not using any outer > join here. Using a simplified version of the original two models: > >         class Student(models.Model): >            ... > >         class

Re: Foreign Key query question

2009-04-10 Thread Malcolm Tredinnick
On Fri, 2009-04-10 at 05:45 -0700, nikita kozlovsky wrote: > On Mar 9, 3:21 am, Malcolm Tredinnick > wrote: > > Hello, Malcolm. > > > > Again, the correct syntax would be: > > > Message.objects.filter(student__isnull=True) > > Why ORM uses LEFT OUTER JOIN on this

Re: Foreign Key query question

2009-04-10 Thread nikita kozlovsky
On Mar 9, 3:21 am, Malcolm Tredinnick wrote: Hello, Malcolm. > > Again, the correct syntax would be: > > Message.objects.filter(student__isnull=True) Why ORM uses LEFT OUTER JOIN on this query ? Why not "... WHERE student_id IS NULL" ?

Re: Foreign Key query question

2009-03-08 Thread Malcolm Tredinnick
Take it as given that I agree with the bulk of Daniel's reply. It's correct. I have one quibble, however... On Sun, 2009-03-08 at 10:54 -0700, Daniel Roseman wrote: [...] > What do you mean by 'student=1'? Do you mean 'the student whose pk is > 1'? If so, the correct filter syntax for this on

Re: Foreign Key query question

2009-03-08 Thread Christoph Wegscheider
On 8 Mrz., 18:54, Daniel Roseman wrote: > On Mar 8, 3:50 pm, Christoph Wegscheider > > > > wrote: > > Hi, > > I have the following model: > > class Message(models.Model): > >     student = models.ForeignKey(Student,  blank=True,  

Re: Foreign Key query question

2009-03-08 Thread Daniel Roseman
On Mar 8, 3:50 pm, Christoph Wegscheider wrote: > Hi, > I have the following model: > class Message(models.Model): >     student = models.ForeignKey(Student,  blank=True,  null=True) >     message = models.CharField(max_length=200) > > I want to filter for: >

Foreign Key query question

2009-03-08 Thread Christoph Wegscheider
Hi, I have the following model: class Message(models.Model): student = models.ForeignKey(Student, blank=True, null=True) message = models.CharField(max_length=200) I want to filter for: message_list = Message.objects.filter(student=1) OR message_list =