within a view you could use
news_list = news.get_list(user__id__exact=request.user.id)
for the logged-in user

to get the user within the template use
news.get_user.username
...

http://www.djangoproject.com/documentation/db_api/#many-to-one-relations

hope that helps,
patrick

> 
> Hi,
> 
> 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?)

> With approach 2, somehow in my NewsPosting table I have to add a field
> called user_id, that lets me know which user was responsible for this
> posting, and add a function to NewsPosting: get_user() and another
> function to User: get_newsposting_list() which isn't as clean either.
> There must be an easier way to do this with Django, or if not I think
> it's a good feature to add!
> 
> I like approach #2 better.
> 
> Regards,
> Mike
> 

Reply via email to