Re: Limit choices based on a foreign key

2009-10-22 Thread Tim Valenta
I would very much be interested in a solution to this problem. I can't yet understand why Django is so wonderful at so many things, yet has absolutely no mechanism for this. Every time there seems to be hope of a working solution, it never works for inlines. For the sake of painting up another

Re: Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer
Ok, I found a way, but it's still not perfect. class GoalForm(forms.ModelForm): class Meta: model = Goal def __init__(self, *args, **kwargs): super(GoalForm, self).__init__(*args, **kwargs) self.fields['goal_scorer'].queryset = Player.objects.filter(gameroster__g

Re: Limit choices based on a foreign key

2009-10-12 Thread Peter Flood
It might not help your immediate problem but since players and teams are the fundamental entities involved in team sports I'm sure you'll need an easy way of linking them at some point. --~--~-~--~~~---~--~~ You received this message because you are subscribed to t

Re: Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer
Hi Peter, I forgot to post some important relations in the models. GameRoster is a table in a m2m relation between Player and Game. I need some extra attributes on the relationship between player and game (which position they played). class GameRoster(models.Model): player = models.ForeignKey

Re: Limit choices based on a foreign key

2009-10-12 Thread pe...@whywouldwe.com
Seems odd to connect Player to Team via Goal and GameRoster (only for hometeam, presumably you have away team as well) - what about players that don't score, don't you want those details as well? Maybe you show an edited version of your models. Why not have class Player(models.Model): las

Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer
Hi, I have a question regarding the admin interface of django. My models class Team(models.Model): name = models.CharField(max_length=10) class Player(models.Model): lastname = models.CharField(max_length=60) class Goal(models.Model): game = models.ForeignKey(Game) goal_scorer