Looks like you skiped a huge part of the tutorial. you might to go back...

On Thursday, June 7, 2018 at 11:08:15 AM UTC-4, Avitab Ayan Sarmah wrote:
>
> In windows powershell:
>
> ERRORS:
> <class 'polls.admin.QuestionAdmin'>: (admin.E108) The value of 
> 'list_display[0]' refers to 'question_text', which is not a callable, an 
> attribute of 'QuestionAdmin', or an attribute or method on 'polls.Question'.
> <class 'polls.admin.QuestionAdmin'>: (admin.E108) The value of 
> 'list_display[1]' refers to 'pub_date', which is not a callable, an 
> attribute of 'QuestionAdmin', or an attribute or method on 'polls.Question'.
> <class 'polls.admin.QuestionAdmin'>: (admin.E116) The value of 
> 'list_filter[0]' refers to 'pub_date', which does not refer to a Field.
>
> System check identified 3 issues (0 silenced).
>
> polls\models.py:
>
> import datetime
>
> from django.db import models
> from django.utils import timezone
>
>
> class Question(models.Model):
>     #...
>     def was_published_recently(self):
>         now = timezone.now()
>         return now - datetime.timedelta(days=1) <= self.pub_date <= now
>     was_published_recently.admin_order_field = 'pub_date'
>     was_published_recently.boolean = True
>     was_published_recently.short_description = 'published recently?'
> class Choice(models.Model):
>     #...
>     def __str__(self):
>         return self.choice_text
>     question = models.ForeignKey(Question, on_delete=models.CASCADE)
>     choice_text = models.CharField(max_length=200)
>     votes = models.IntegerField(default=0)
>
>
> polls\admin.py:
>
>
> from django.contrib import admin
>
> from . models import Choice, Question
>
>
> class ChoiceInline(admin.TabularInline):
>     model = Choice
>     extra = 3
>
>
> class QuestionAdmin(admin.ModelAdmin):
>     fieldsets = [
>         (None,              {'fields': ['question_text']}),
>         ('Date information',{'fields': ['pub_date'], 'classes': 
> ['collapse']}),
>     ]
>     inlines = [ChoiceInline]
>     list_display = ('question_text', 'pub_date', 'was_published_recently')
>     list_filter = ['pub_date']
>
> admin.site.register(Question, QuestionAdmin)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c65b7f0-9ca7-4e07-8167-fb29274710e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to