I have two models, UserProfile and Team[2]. I want to create a Team page which lists all the users who belong to that team. I'm not sure how to specify this in my view. [1] The problem I run into is that team doesn't exist within User.
Any advice on how to query User for a particular team name? TIA Adam [1] def team_page(request, team_name): try: team = Team.objects.get(team=team_name) except: raise Http404 ('No team found') u = User.objects.get(team=team_name) users = u.get_profile().user template = get_template('team_page.html') variables = Context({ 'team': team, 'users': users }) output = template.render(variables) return HttpResponse(output) [2] class Team(models.Model): team = models.TextField(unique=True) def __str__(self): return str(self.team) class Admin: pass class UserProfile(models.Model): score = models.IntegerField() team = models.ForeignKey(Team) user = models.ForeignKey(User) def __str__(self): return str(self.user) class Admin: pass -- You back your data up on the same planet? http://www.monkeez.org PGP key: 0x7111B833 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---