Code snippets:
class HighscoreAdmin(admin.ModelAdmin):
list_display = ('name', 'score')
...
and
class Highscore(models.Model):
name = models.CharField(max_length=128)
score = models.PositiveIntegerField(default=0)
...
Question:
Let's say we have a score value of 100000. In Admin, it will display the score as 1000000, but what if I want a different format? How would you change the format to output -> 1,000,000?
I heard that you could add a method to the Highscore class something like foo_display, where foo is the field in question:
def score_display(self):
""" returns scores with commas as thousands separators in the admin display """
return '{:,}'.format(self.score)