Django Error (admin.E106) ModelInline must have a 'model' attribute

Was just following the tutorials from Django documentation. In Writing your first Django app, part 7, the tutorial was adding the Choice section when a user is adding a Question. In the documentation, the code seems to work fine, but in my system, for some reason it isn't working. Please tell me where I got it wrong.


from django.contrib import admin
from .models import Choice, Question

# Register your models here.

class ChoiceInline(admin.TabularInline):
    model: Choice
    extra: 3

class QuestionAdmin(admin.ModelAdmin):
    # fields = ['pub_date', 'question_text']
    fieldsets = [
        (None, {'fields': ['question_text']}),
        ('Date Information', {'fields': ['pub_date'],
    inlines = [ChoiceInline], QuestionAdmin)


<class 'polls.admin.QuestionAdmin'>: (admin.E105) 'polls.admin.ChoiceInline' must have a 'model' attribute.
Back to Top