On 1/9/06, Mike <[EMAIL PROTECTED]> wrote: > I have a model with multiple companies (Basecamp Style), where each > have multiple users and multiple company news. Which of the two way is > more appropriate: > > 1: Company -----one-to-many----> User ----one-to-many----> NewsPosting > > 2: Company -----one-to-many----> User > |------------one-to-many----> NewsPosting > > Where Company, User and NewsPosting are tables. > > With approach 1, I have to add a function to Company called > get_newsposting_list() that gets the list of postings for a company > through SQL. (Is there any easier way to do this? Can't django automate > this process?)
Yes, Django can automate this process. With approach one (which I'd recommend), you could do this: newspostings.get_list(user__company__id__exact=123) This takes advantage of the fact that the lookup parameters are capable of performing joins behind the scenes. Let me know if this doesn't make sense or if I misunderstood your question. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org