Tuesday, August 27, 2013

django 2 tables one query?

Hi 

I was wondering is it possible to get information about two tables in one query?
I have two models 
Team (id, name, active, country) and Player (id, first_name, second_name, active, team)
where Player.team = ForeignKey(Team)
Of course one team may have several players and one player have one team.

Is it possible to get only one, random, player of each team?
for db i use mysql

best regards
slawek

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment