On 2/1/07, Giorgio Salluzzo <[EMAIL PROTECTED]> wrote:
>
> 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.

See http://djangoproject.com/documentation/model_api/#relationships
for more details.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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