users App:
import xadmin
from .models import EmailVerifyRecord, Banner, UserProfile
class UserProfileAdmin(object):
pass
class EmailVerifyRecordAdmin(object):
list_display = ['code', 'email', 'send_type', 'send_time'] #后台自定义显示列
search_fields = ['code', 'email', 'send_type'] #定义后台搜索
list_filter = ['code', 'email', 'send_type', 'send_time'] #通过时间搜索
# list_display = ('code',)
class BannerAdmin(object):
list_display = ['title', 'image', 'url', 'index', 'add_time'] #后台自定义显示列 显示字段
search_fields = ['title', 'image', 'url', 'index'] #定义后台搜索 搜索功能
list_filter = ['title', 'image', 'url', 'index', 'add_time'] #过滤器 通过时间搜索
xadmin.site.register(UserProfile, UserProfileAdmin)
xadmin.site.register(EmailVerifyRecord, EmailVerifyRecordAdmin)
xadmin.site.register(Banner, BannerAdmin)
organization App:
# -*- coding:utf-8 -*-
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 = ['name', 'desc', 'click_nums', 'fav_nums']
search_fields = ['name', 'desc', 'click_nums', 'fav_nums']
list_filter = ['name', 'desc', 'click_nums', 'fav_nums']
class TeacherAdmin(object):
list_display = ['org', 'name', 'work_years', 'work_company']
search_fields = ['org', 'name', 'work_years', 'work_company']
list_filter = ['org', 'name', 'work_years', 'work_company']
xadmin.site.register(CityDict, CityDictAdmin)
xadmin.site.register(CourseOrg, CourseOrgAdmin)
xadmin.site.register(Teacher, TeacherAdmin)
operation App:
# -*- coding:utf-8 -*-
from .models import UserAsk, CourseComments, UserFavorite, UserMessage, UserCourse
import xadmin
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__nick_name', 'course__name', '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__nick_name', 'fav_id', 'fav_type', 'add_time']
# 用户消息
class UserMessageAdmin(object):
list_display = ['user', 'message', 'has_read', 'add_time']
search_fields = ['user', 'message', 'has_read']
# 这里的 user 不是 ForeignKey ,具体请看 models.py
list_filter = ['user', 'message', 'has_read', 'add_time']
class UserCourseAdmin(object):
list_display = ['user', 'course', 'add_time']
search_fields = ['user', 'course']
list_filter = ['user__nick_name', 'course__name', '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)
courses App:
# -*- coding:utf-8 -*-
from .models import Course, Lesson, Video, CourseResource
import xadmin
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']
# course 是一个对象,xadmin 不能搜索,需要指定搜索 course 对象里哪一个属性
list_filter = ['course__name', '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', 'download', 'add_time']
search_fields = ['course', 'name', 'download']
list_filter = ['course__name', 'name', 'add_time']
xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Video, VideoAdmin)
xadmin.site.register(CourseResource, CourseResourceAdmin)
效果如下:
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
多线程可以同时处理多个任务,支持并发处理,从而提高系统的并发能力。多线程爬虫的好处主要有提高爬取效率、提高稳定性、节省资源等。总之,多线程爬虫可以提高爬取效率、稳定性和资源利用率,是一种更加高效、可靠的爬虫实现方式。 多线程爬虫并行可以提高爬虫的效率,具体实现…