Registering the models in the administration site

Let's add the course models to the administration site. Edit the admin.py file inside the courses application directory and add the following code to it:

from django.contrib import adminfrom .models import Subject, Course, Module@admin.register(Subject)class SubjectAdmin(admin.ModelAdmin):    list_display = ['title', 'slug']    prepopulated_fields = {'slug': ('title',)}class ModuleInline(admin.StackedInline):    model = Module@admin.register(Course)class CourseAdmin(admin.ModelAdmin):    list_display = ['title', 'subject', 'created']    list_filter = ['created', 'subject']    search_fields = ['title', 'overview']    prepopulated_fields = {'slug': ('title',)}    inlines = [ModuleInline]

The models for the course application ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.