Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread Suriya
DavidA wrote: > Suriya, > > You will probably have to do this in custom SQL or using extra(). Your > query requires a subselect to get the "current B's" (B's with max(date) > for each A). > > Here's the SQL that I think you need (if I understand the problem > correctly): > > select * from _A join

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread SmileyChris
Suriya wrote: > This returns the list of rows in table A that have status > in table B set to 1 at some point in the past. What I want > is the latest status from table B. I see. Yes, you can either use a (grouping) custom SQL query or refactor. How I would do it is to have just one model (B)

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread DavidA
Suriya, You will probably have to do this in custom SQL or using extra(). Your query requires a subselect to get the "current B's" (B's with max(date) for each A). Here's the SQL that I think you need (if I understand the problem correctly): select * from _A join _B on _B.a_id = _A.id where

Re: Database API question: I am not able to return a QuerySet

2006-07-31 Thread Suriya
SmileyChris wrote: > How about just making the query like this: > > A.objects.filter(b__status=1) This returns the list of rows in table A that have status in table B set to 1 at some point in the past. What I want is the latest status from table B. For example, if table B has the two entries:

Re: Database API question: I am not able to return a QuerySet

2006-07-30 Thread SmileyChris
How about just making the query like this: A.objects.filter(b__status=1) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To

Database API question: I am not able to return a QuerySet

2006-07-30 Thread Suriya
Hi all, I have a situation here where I do not know how to use the filter() function in the database API to obtain a QuerySet. I am describing the schema and what I have done, below. I hope you have an answer to my question. # Only the necessary fields are shown here class A(models.Model):