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

Posted 起航追梦人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django打造在线教育平台_day_3: 搭建后台管理系统Xadmin之其他app的数据表注册相关的知识,希望对你有一定的参考价值。

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)

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)

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)

 

以上是关于Django打造在线教育平台_day_3: 搭建后台管理系统Xadmin之其他app的数据表注册的主要内容,如果未能解决你的问题,请参考以下文章

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

Django打造在线教育平台_day_3:全局配置

Django打造在线教育平台_day_3:之处理外建搜索无效

Django打造在线教育平台_day_4: 完成注册功能

Django打造在线教育平台_day_4: 前台逻辑的编写之配置首页与登录

Django打造在线教育平台_day_4: 完成用户登录功能