I have the following model settings
class Player(models.Model):
Player_Name = models.CharField(max_length=100)
Nick = models.CharField(max_length=100, blank=True)
Jersy_Number = models.IntegerField()
Team_id = models.ForeignKey('Team')
Postion_Choices = (
('M', 'Manager'),
('P', 'Player'),
)
Poistion = models.CharField(max_length=1, blank=True, choices =Postion_Choices)
Red_card = models.IntegerField( blank=True, null=True)
Yellow_card = models.IntegerField(blank=True, null=True)
Points = models.IntegerField(blank=True, null=True)
class PlayerAdmin(admin.ModelAdmin):
list_display = ('Player_Name',)
search_fields = ['Player_Name',]
admin.site.register(Player, PlayerAdmin)
class Team(models.Model):
"""Model docstring"""
Team_Name = models.CharField(max_length=100,)
College = models.CharField(max_length=100,)
Win = models.IntegerField(blank=True, null=True)
Loss = models.IntegerField(blank=True, null=True)
Draw = models.IntegerField(blank=True, null=True)
class Meta:
pass
@models.permalink
def get_absolute_url(self):
return ('view_or_url_name')
class TeamAdmin(admin.ModelAdmin):
list_display = ('Team_Name',)
search_fields = ['Team_Name',]
admin.site.register(Team, TeamAdmin)
My question is: how can I get to the admin site to show Team_namein the "add player" field Team_ID, at present it only appears as Team objectin the combo box
source
share