> > class Project
> >     ...
> >     staff = models.ManyToMany(User)
>
> > My concern is the fact that I should loop over all my projects and get
> > the staff for each ot them.
>
> If Project has a ManyToMany field, then Users will have a field called
> project_set.
>
> frank = User.objects.get(name='Frank')
> print frank.project_set
>
> will print all of the projects that Frank is involved in.
>
> The name project_set is automatically generated - you can override it
> if you want using the 'related_name' argument on the ManyToMany
> definition.

I think that Giorgio wanted to know if he needs to loop "manually"
over project_set or if there is a possibility to get  the list of
users (of each project) in one single queryset.

sort of a (NOT CORRECT):

   frank.project_set.all().staff

I personally don't know eather...

sandro
*;-)


--~--~---------~--~----~------------~-------~--~----~
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 unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to