Hello All, So in my models.py file, I have:
class Player(models.Model): team = models.ForeignKey(Team) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) gp = models.IntegerField(max_length=2) #games played mp = models.IntegerField(max_length=4) #minutes played def mpg(self): #minutes per game return self.mp/self.gp def __unicode__(self): return self.first_name+' '+self.last_name When I run "python manage.py shell" and try to pull up a player's "mpg", I get: >>> p = Player.objects.get(last_name='Durant') >>> p <Player: Kevin Durant> >>> p.mp 1027 >>> p.gp 27 >>> p.mpg <bound method Player.mpg of <Player: Kevin Durant>> How do I get the API to return '38' and not <bound method of blah blah blah>? I realize this probably has something to do with telling the models.py file how to represent p.mpg with some kind of __unicode__() method, but I don't know exactly what that code should be or where it should go relative to the "def mpg(self)" method... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.