Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing Django admin with list_display?

I'm trying to customize the Django Admin.

models.py 
=============
class Question(models.Model):
    poll = models.ForeignKey(Poll)
    name = models.CharField(max_length=100)
    pub_date = models.DateTimeField('date published')

admin.py
===========   
class QuestionAdmin(admin.ModelAdmin):
    list_display = ('name', 'poll'. 'pub_date')
    inlines = [ChoiceInline]

admin.site.register(Question)

That seems to be the correct setup for customizing the QuestionIndex.
I want this displayed:
What is your question? introPoll July 31, 2009

However, the only the default unicode is showing up on the Question index.

Am I missing a step?

What could be some reasons the additional data is not being displayed on the index?

like image 400
BryanWheelock Avatar asked Dec 06 '22 05:12

BryanWheelock


1 Answers

You must specify the admin class in the admin.site.register function if you've customized it:

admin.site.register(Question, QuestionAdmin)

Also, I assume it's a typo, but the list_display has a period where there should be a comma: ('name', 'poll'. 'pub_date') should be ('name', 'poll', 'pub_date').

like image 175
jds Avatar answered Dec 26 '22 20:12

jds