Django打造在线教育平台_day_3: 搭建后台管理系统Xadmin之其他app的数据表注册

1、courses/adminx.py

import xadmin
from .models import Course, Lesson, Video, CourseResource

class CourseAdmin(object):
    list_display = ['name', 'desc', 'detail', 'degree','learn_times', 'students','fav_nums','image','click_nums','add_time']  # 列表显示
    search_fields = ['name', 'desc', 'detail', 'degree','learn_times', 'students','fav_nums','image','click_nums']   # 搜索
    list_filter = ['name', 'desc', 'detail', 'degree','learn_times', 'students','fav_nums','image','click_nums','add_time']  # 筛选

class LessonAdmin(object):
    list_display = ['course', 'name', 'add_time']  # 列表显示
    search_fields = ['course', 'name']  # 搜索
    list_filter = ['course', 'name', 'add_time']   # 筛选

class VideoAdmin(object):
    list_display = ['lesson', 'name', 'add_time']  # 列表显示
    search_fields = ['lesson', 'name']  # 搜索
    list_filter = ['lesson', 'name', 'add_time']   # 筛选

class CourseResourceAdmin(object):
    list_display = ['course', 'name', 'add_time','download']  # 列表显示
    search_fields = ['course', 'name','download']  # 搜索
    list_filter = ['course', 'name', 'add_time','download']   # 筛选

xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Video, VideoAdmin)
xadmin.site.register(CourseResource, CourseResourceAdmin)

2、operation/adminx.py

import xadmin
from .models import UserAsk, CourseComments, UserFavorite, UserMessage, UserCourse

class UserAskAdmin(object):
    list_display = ['name', 'mobile', 'course_name','add_time']  # 列表显示
    search_fields = ['name', 'mobile', 'course_name'] # 搜索
    list_filter = ['name', 'mobile', 'course_name','add_time']  # 筛选

class CourseCommentsAdmin(object):
    list_display = ['user', 'course', 'comments','add_time']  # 列表显示
    search_fields = ['user', 'course', 'comments']   # 搜索
    list_filter = ['user', 'course', 'comments','add_time']   # 筛选

class UserFavoriteAdmin(object):
    list_display = ['user', 'fav_id', 'fav_type','add_time']  # 列表显示
    search_fields = ['user', 'fav_id', 'fav_type'] # 搜索
    list_filter = ['user', 'fav_id', 'fav_type','add_time']  # 筛选


class UserMessageAdmin(object):
    list_display = ['user', 'message', 'has_read','add_time']  # 列表显示
    search_fields = ['user', 'message', 'has_read'] # 搜索
    list_filter = ['user', 'message', 'has_read','add_time']   # 筛选

class UserCourseAdmin(object):
    list_display = ['user', 'course', 'add_time']  # 列表显示
    search_fields = ['user', 'course']   # 搜索
    list_filter = ['user', 'course', 'add_time']    # 筛选

xadmin.site.register(UserAsk, UserAskAdmin)
xadmin.site.register(CourseComments, CourseCommentsAdmin)
xadmin.site.register(UserFavorite, UserFavoriteAdmin)
xadmin.site.register(UserMessage, UserMessageAdmin)
xadmin.site.register(UserCourse, UserCourseAdmin)

3、organization/adminx.py

import xadmin
from .models import CityDict, CourseOrg, Teacher

class CityDictAdmin(object):
    list_display = ['name', 'desc','add_time']  # 列表显示
    search_fields = ['name', 'desc']  # 搜索
    list_filter = ['name', 'desc','add_time']    # 筛选

class CourseOrgAdmin(object):
    list_display = ['city', 'name','desc','click_nums','fav_nums','image','address','add_time']  # 列表显示
    search_fields = ['city', 'name','desc','click_nums','fav_nums','image','address']   # 搜索
    list_filter = ['city', 'name','desc','click_nums','fav_nums','image','address','add_time']     # 筛选

class TeacherAdmin(object):
    list_display = ['org', 'name','work_years','work_company','work_position','points','click_nums','fav_nums','add_time']  # 列表显示
    search_fields = ['org', 'name','work_years','work_company','work_position','points','click_nums','fav_nums']  # 搜索
    list_filter = ['org', 'name','work_years','work_company','work_position','points','click_nums','fav_nums','add_time']    # 筛选

xadmin.site.register(CityDict, CityDictAdmin)
xadmin.site.register(CourseOrg, CourseOrgAdmin)
xadmin.site.register(Teacher, TeacherAdmin)

 

posted @ 2017-06-24 12:12  起航追梦人  阅读(1560)  评论(0编辑  收藏  举报