Overwrite queryset which builds filter sidebar

Posted by cw on Stack Overflow See other posts from Stack Overflow or by cw
Published on 2010-05-02T11:36:46Z Indexed on 2010/05/02 11:47 UTC
Read the original article Hit count: 243

Filed under:
|

Hi,
I'm writing a hockey database/manager. So I have the following models:

class Team(models.Model):
   name = models.CharField(max_length=60)

class Game(models.Model):
   home_team = models.ForeignKey(Team,related_name='home_team')
   away_team = models.ForeignKey(Team,related_name='away_team')

class SeasonStats(models.Model):
   team = models.ForeignKey(Team)

Ok, so my problem is the following. There are a lot of teams, but Stats are just managed for my Club. So if I use "list_display" in the admin backend, I'd like to modify/overwrite the queryset which builds the sidebar for filtering, to just display our home teams as a filter option.
Is this somehow possible in Django?

I already made a custom form like this

class SeasonPlayerStatsAdminForm(forms.ModelForm):
   team = forms.ModelChoiceField(Team.objects.filter(club__home=True))

So now just the filtering is missing. Any ideas?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-admin