14.管理后台-候选人信息筛选和查询

69 阅读1分钟

需求

  • 能够按照名字、手机号码、学校来查询候选人信息
  • 能够按照初试结果,复试结果,HR复试结果,面试官来筛选;能按照复试结果来排序

wangdalei_dj/interview/admin.py

from django.contrib import admin

# Register your models here.

from interview.models import Candidate


# 候选人管理类
class CandidateAdmin(admin.ModelAdmin):
    list_display = (
        'username', 'city', 'bachelor_school', 'first_score', 'first_result', 'first_interviewer_user',
        'second_score',
        'second_result', 'second_interviewer_user', 'hr_score', 'hr_result', 'hr_interviewer_user',)


    # 右侧筛选条件
    list_filter = ('city','first_result','second_result','hr_result','first_interviewer_user','second_interviewer_user','hr_interviewer_user')

    # 查询字段
    search_fields = ('username', 'phone', 'email', 'bachelor_school')


admin.site.register(Candidate, CandidateAdmin)

image.png

### 列表页排序字段
ordering = ('hr_result', 'bachelor_school', 'second_result', 'first_result',)

添加排序功能 image.png