Source

HH-Courses / admin.py

from django.contrib import admin
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
from models import Courses, Lessons, Media

class MediaInline(admin.TabularInline):
	model = Media
	extra = 2

class CoursesAdmin(admin.ModelAdmin):		
	fields = ['title', 'discussion', 'summary', 'is_published', 'sites']
	list_display = ['title', 'is_published',]
	list_filter = ['createdate']
	date_hierarchy = 'createdate'
	search_fields = ['title']

class LessonsAdmin(admin.ModelAdmin):		
	fields = ['course', 'title', 'summary', 'content', 'is_published']
	list_display = ['title', 'is_published',]
	list_filter = ['createdate']
	date_hierarchy = 'createdate'
	search_fields = ['title']
        inlines = [MediaInline]
        
class MediaAdmin(admin.ModelAdmin):		
	fields = ['lesson', 'title', 'media', 'type']
	list_display = ['title', 'media',]
	list_filter = ['createdate']
	date_hierarchy = 'createdate'
	search_fields = ['title']   


admin.site.register(Courses, CoursesAdmin)
admin.site.register(Lessons, LessonsAdmin)
admin.site.register(Media, MediaAdmin)