In tutorial here I get down to where you run was_published_recently and I get this error:
ImproperlyConfigured at /admin/polls/poll/
PollAdmin.list_display[2], ‘was_published_recently’ is not a callable or an attribute of ‘PollAdmin’ or found in the model ‘Poll’.
Request Method: GET
Request URL: /admin/polls/poll/
Django Version: 1.4
Exception Type: ImproperlyConfigured
Exception Value:
PollAdmin.list_display[2], ‘was_published_recently’ is not a callable or an attribute of ‘PollAdmin’ or found in the model ‘Poll’.
Exception Location: C:\Python27\lib\site-packages\django\contrib\admin\validation.py in validate, line 38
here is my code:
from polls.models import Poll
from django.contrib import admin
from polls.models import Choice
class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3
class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
]
inlines = [ChoiceInline]
class PollAdmin(admin.ModelAdmin):
# ...
list_display = ('question', 'pub_date', 'was_published_recently')
admin.site.register(Poll, PollAdmin)
here is my poll model
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()
class Poll(models.Model):
# ...
def __unicode__(self):
return self.question
class Choice(models.Model):
# ...
def __unicode__(self):
return self.choice
Can you update your question with your
Pollmodel?It looks like you may have made a mistake when adding the
was_published_recentlymethod to yourPollmodel in the Playing with the API step in Tutorial 1.Update:
Now that you’ve posted your model, it does look as if you’ve missed out the
was_published_recentlymethod. Go back over tutorial 1 and add it in.Secondly, don’t include each model more than once in models.py – the second one will replace the first.