Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialErwin Paolo Yumul
13,852 PointsError in admin.py
Hello, I have this code in admin.py
from django.contrib import admin
from .models import Course, Step
# Register your models here.
class StepInline(admin.StackedInline):
models = Step
class CourseAdmin(admin.ModelAdmin):
inlines = [StepInline,]
admin.site.register(Course, CourseAdmin)
admin.site.register(Step)
Error:
<class 'courses.admin.CourseAdmin'>: (admin.E105) 'courses.admin.StepInline' must have a 'model' attribute.
The error occurs in this line:
admin.site.register(Course, CourseAdmin)
Please help.
1 Answer
jacinator
11,936 Pointsfrom django.contrib import admin
from .models import Course, Step
# Register your models here.
class StepInline(admin.StackedInline):
models = Step # This is the line with the error. Look closely at this line and at the error.
class CourseAdmin(admin.ModelAdmin):
inlines = [StepInline,]
admin.site.register(Course, CourseAdmin)
admin.site.register(Step)