Friday, June 24, 2011

Help selecting info from across databases in queries.

Here are my models:

http://dpaste.com/558411/

I'm wanting to run a query on the Team model that gets every game from
Games where the team's opponent was in the Coaches Poll Top 25.

So, the view is getting:

team = Team.objects.get(pk=team_id)

On this page, it'll display team info (I cut out location, and more
fields in the Team model that are just kind of fluff info), then I
want to display below that every game from the Games table where the
the team played an opponent who has an entry in TeamInfo.coaches that
is less than, or equal to, 25.

I can get all the teams games by:

games = Games.objects.filter( Q(team1__team__team=team) |
Q(team2__team__team=team))

I just don't know how to get the stuff from TeamInfo that I need.
Should I restructure my models?

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate