Django Admin football game registration

1

Please help me. I'm learning Django.

I have a site that registers some games in my city. Here is an example to understand the doubt:

Championship: Holidays 2017

It has 2 groups (Group 1 and Group 2)

I registered 6 teams (São Paulo, Barcelona, Palmeiras, etc ...)

In group 1 there are teams: Arsenal, Botagogo, and Cruzeiro

In group 2 there are teams: Palmeiras, Real Madrid and São Paulo

My question is: When I select group 1, it lists only teams from group 1 to "play with each other" by Django Admin

See the picture below, first select the group (in case group 1).

Intheteamlist,comeallteams,eventhoseingroup2

followfonts:

admin.py

classJogoAdmin(admin.ModelAdmin):fields=('grupo','data_jogo','estadio','clube_casa','clube_visitante','gols_casa','gols_visitante','jogo_realizado',)

model.py

classJogo(models.Model):grupo=models.ForeignKey(Grupo,on_delete=models.CASCADE,related_name='jogo_grupo')data_jogo=models.DateTimeField()estadio=models.ForeignKey(Estadio,on_delete=models.PROTECT,related_name='jogo_estadio')clube_casa=models.ForeignKey(Clube,related_name="jogo_clubecasa", on_delete=models.PROTECT)
    clube_visitante = models.ForeignKey(Clube, related_name="jogo_clubevisitante", on_delete=models.PROTECT)
    gols_casa = models.IntegerField(default=0)
    gols_visitante = models.IntegerField(default=0)
    jogo_realizado = models.BooleanField(default=False)
    data_cadastro = models.DateTimeField(auto_now_add=True)

class GrupoClube(models.Model):
    # Aqui é onde cadastro os times nos grupos
    grupo = models.ForeignKey(Grupo, on_delete=models.CASCADE, related_name='grupoclube_grupo')
    clube = models.ForeignKey(Clube, on_delete=models.CASCADE, related_name='grupoclube_clube')
    data_cadastro = models.DateTimeField(auto_now_add=True)

full source on: link

    
asked by anonymous 25.06.2017 / 23:53

0 answers