I have a django site. a snippet of myapp/models.py looks like this:
class Continent(models.Model):
name = models.CharField(max_length=128, db_index=True, unique=True)
class GeographicRegion(models.Model):
continent = models.ForeignKey(Continent, null=False)
name = models.CharField(max_length=128, null=False)
When I am attempting to add new geographic regions, when I click the drop down list (select control) to choose a continent, the only values (options) in the drop down list are:
continent object
continent object
continent object
continent object
continent object
continent object
I was expecting to see the names of the continents instead, so I could create relevant geographic regions per continent. How do I get the name to show in the list instead of 'continent object'?
Hint: i added str(self) and repr(self) methods to my ContinentAdmin model in myapp/admin.py like this:
myapp/admin.py
58 class ContinentAdmin(admin.ModelAdmin):
59 def __repr__(self):
60 return self.name
61
62 admin.site.register(Continent,ContinentAdmin)
, however this had no (observable) effect