Commit 713e7680 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

customized admin interface for Students and Majors

parent c571fe57
......@@ -5,6 +5,24 @@ from django.contrib import admin
# imports from your apps
from .models import Student, Major, Confirmation
class StudentAdmin(admin.ModelAdmin):
list_display = ("get_name", "room", "privacy", "major", "created")
def get_name(self, student):
return student.get_full_name_or_uname()
get_name.short_description = 'Name'
get_name.admin_order_field = 'user__username' # ordering by callables is hard
class MajorAdmin(admin.ModelAdmin):
list_display = ("name", "get_major_num", )
def get_major_num(self, major):
student_num = Student.objects.filter(major=major).count()
return student_num
get_major_num.short_description = 'Number of Students'
# ordering is hard (ditto above; rewrite queryset :-/), StudentAdmin), MajorAdmin)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment