Forums

List of records in Admin just says 'object', not a useful description of document

Hi,

I am working on the Django tutorial. (https://docs.djangoproject.com/en/1.6/intro/tutorial01/)

I setup the initial admin for an app, but in the list of records in Admin it just says 'object', not a useful description of the document.

The tutorial (in the link above) instructs the following:

"Wait a minute. <Poll: Poll object> is, utterly, an unhelpful representation of this object. Let’s fix that by editing the polls model (in the polls/models.py file) and adding a unicode() method to both Poll and Choice. On Python 3, simply replace unicode by str in the following example:"

I did this, but the list of records in Admin is still showing 'object'. And I am using Python 3, so I used str instead of unicode per the instructions.

Any idea?

Did you reload your web app?

Hi glenn,

Thanks for your response. Yes, I clicked the 'Reload mikebak.pythonanywhere.com' button. It is still showing 'object' in the list, instead of a useful description(s) for the documents.

Please let me know if my problem is unclear and screenshots or more detail would help.

Thanks.

Here is my code in models.py:

class Races(models.Model): date_of_race = models.DateField() race_name = models.CharField(max_length=50) def str(self): return self.race_name

Got it!

It needed two underscores before and after, not one. I was typing str and it needs str (or to see clearly _ str _)

This must be a level 1 test for newbies like myself :)

glad you figured it out! :)

Thanks Harry!