Hi!
I have a model like this:

class company(models.model):
name = models.CharField(mx_length=20)
 class employee(models.model):
comany = models.ForeignKey(company)
 class user(models.model):
person = models.OneToOneField(person)

One company can have multiple employees but one employee only can have one
user.

I know how to get all employees for a company

company.objects.get(name='companyname').employee_set.all()

But.. How can I get all users for a company?

I try with

user.objects.get(employee=company.objects.get(name='companyname').employee_set.all())
company.objects.get(name='companyname').employee_set.all().user

but this approach only works with a single object, like this:

user.objects.get(employee=company.objects.get(name='companyname').employee_set.all()[2])
company.objects.get(name='companyname').employee_set.all()[2].user

any idea in how can I get all users for a company?

Thanks a lot!
Marc.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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