You can add list_display = ['question', ] on your PollAdmin class. 2012/4/11 Romain Gaches <romain.gac...@gmail.com>: > you just have to define a __unicode__ method [1] in your model > > [1] > https://docs.djangoproject.com/en/1.4/ref/models/instances/#django.db.models.Model.__unicode__ > > > Le 11/04/2012 06:54, oneroler a écrit : > > I'm working on the tutorial and ran across an issue that I can't figure > out. In the admin site in "Select Polls to Change" instead of displaying > the question associated with the poll (e.g. "What's up") it displays "poll > object" for all polls. I've attached a screen shot of the issue. Below is > my code. Any help would be appreciated. > > mysite/polls.models.py > from django.db import models > > class Poll(models.Model): > question = models.CharField(max_length=200) > pub_date = models.DateTimeField('date published') > > class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(max_length=200) > votes = models.IntegerField() > > mysite/polls/admin.py > from polls.models import Poll, Choice > from django.contrib import admin > > class PollAdmin(admin.ModelAdmin): > fieldsets = [ > (None, {'fields': ['question']}), > ('Date information', {'fields': ['pub_date'], 'classes': > ['collapse']}), > ] > > admin.site.register(Poll, PollAdmin) > admin.site.register(Choice) > > mysite/settings.py > DATABASES = { > 'default': { > 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', > 'mysql', 'sqlite3' or 'oracle'. > 'NAME': > '/Users/Sam/dev/django/mysite/mysite1.sqlite', # Or > path to database file if using sqlite3. > 'USER': '', # Not used with sqlite3. > 'PASSWORD': '', # Not used with sqlite3. > 'HOST': '', # Set to empty string for > localhost. Not used with sqlite3. > 'PORT': '', # Set to empty string for default. > Not used with sqlite3. > } > } > > INSTALLED_APPS = ( > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.messages', > 'django.contrib.staticfiles', > # Uncomment the next line to enable the admin: > 'django.contrib.admin', > # Uncomment the next line to enable admin documentation: > # 'django.contrib.admindocs', > 'polls', > ) > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/r6d6l_4q6fUJ. > 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. > > > -- > 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.
-- 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.