views:

61

answers:

2

I am setting up the admin page so that I might be able to use it to add data, players in this case. When you go and attempt to register the Players class in admin.py you get the error described in the question title (object 'players' has no attribute 'fields'). Looking through views.py that I pasted a snippet out of below I don't see what it might be referring to.

Sorry if this is a noob question, I'm pretty new to both django and python.

class Players(models.Model):
    player_id        = models.IntegerField(primary_key=True)
    firstname        = models.CharField(max_length=50)
    lastname         = models.CharField(max_length=50)
    team             = models.ForeignKey(Teams)
    Top200rank       = models.IntegerField(null=True, blank=True)
    position         = models.CharField(max_length=25)
    roster_status    = models.ForeignKey(RosterStatus, null=True, blank=True)
    class Meta:
        ordering = ('lastname', 'firstname')
        verbose_name_plural = 'Players'

    def __unicode__(self):
        return u"%s %s" % (self.firstname, self.last_name)
A: 

Did you setup a ModelAdmin?

class PlayersAdmin(admin.ModelAdmin):

+1  A: 

Fix was in admin.py, see below.

Before:

#foozball admin python file

from foozball.leaguemanager.models import Division, Games, RosterStatus, Teams, Players
from django.contrib import admin

admin.site.register(Teams, Players)

After:

foozball admin python file

from foozball.leaguemanager.models import Division, Games, RosterStatus, Teams, Players
from django.contrib import admin

admin.site.register(Teams)
admin.site.register(Players)
CaleyWoods