Django框架实现学生信息管理系统
演示视频:Django学生信息管理系统_腾讯视频
演示界面内容如下
总体概括
注册流程
首先进行输入用户名(邮箱)、密码以及验证码,输入完之后点击注册按钮。如果输入的不正确,提示错误信息。
如果一切信息填写正确无误,调用STMP模块发送激活邮件,用户必须要点击接收到邮箱链接,进行邮件激活后才方可登陆。
即使注册成功,没有激活的用户也不能登陆,用户以get的方式直接重定向到注册页面。
注册登录:
用户能在系统中进行登陆注册和忘记密码进行找回的功能。
个人中心:修改头像,修改密码,修改邮箱,可以看到我的信息。
日志记录:
记录后台人员的操作,方便发现BUG和查看各项调用进行时间。
导航栏:学生信息中有基本信息、年级及成绩信息的模块,能够排序筛选等功能。
多选操作:
可以选择多条记录进行删除操作,还可以在课程列表页可以对不同课程进行排序。
数据页码:
可以设置各项数据在每一页中显示的数量多少,进行翻页功能。
模块列表页:
能够有过滤器功能,在范围内进行查看数据。还能将数据导出为csv,xml,json等数据格式。
model.py
from django.db import models# Create your models here.
class Grades(models.Model):gname = models.CharField(max_length=20)gdate = models.DateTimeField()gteacher = models.CharField(max_length=20)ggirlnum = models.IntegerField()gboynum = models.IntegerField()isDelete = models.BooleanField(default=False)def __str__(self):return self.gnameclass Students(models.Model):sname = models.CharField(max_length=20)sgender = models.BooleanField(default=True)sminzu = models.CharField(max_length=20)sbir = models.IntegerField()scontend = models.CharField(max_length=20)shome = models.CharField(max_length=20)sidcard = models.CharField(max_length=20)sschnum = models.IntegerField()stel = models.CharField(max_length=20)steacher = models.CharField(max_length=20)isDelete = models.BooleanField(default=False)# 关联外键sgrade = models.ForeignKey("Grades", on_delete=models.CASCADE)def __str__(self):return self.sname# class Score(models.Model):
# math = models.IntegerField()# 关联外键sgrade = models.ForeignKey("Grades", on_delete=models.CASCADE)from django.db import models
from django.contrib.auth.models import Group
from django.conf import settings
from django.utils.encoding import python_2_unicode_compatibleAUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')SERVER_STATUS = ((0, u"Normal"),(1, u"Down"),(2, u"No Connect"),(3, u"Error"),
)
SERVICE_TYPES = (('moniter', u"Moniter"),('lvs', u"LVS"),('db', u"Database"),('analysis', u"Analysis"),('admin', u"Admin"),('storge', u"Storge"),('web', u"WEB"),('email', u"Email"),('mix', u"Mix"),
)@python_2_unicode_compatible
class AccessRecord(models.Model):date = models.DateField()user_count = models.IntegerField()view_count = models.IntegerField()class Meta:verbose_name = u"Access Record"verbose_name_plural = verbose_name# def __str__(self):# return "%s Access Record" % self.date.strftime('%Y-%m-%d')from django.db import models
from django.contrib.auth.models import Group
from django.conf import settings
from django.utils.encoding import python_2_unicode_compatibleAUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')SERVER_STATUS = ((0, u"Normal"),(1, u"Down"),(2, u"No Connect"),(3, u"Error"),
)
SERVICE_TYPES = (('moniter', u"Moniter"),('lvs', u"LVS"),('db', u"Database"),('analysis', u"Analysis"),('admin', u"Admin"),('storge', u"Storge"),('web', u"WEB"),('email', u"Email"),('mix', u"Mix"),
)@python_2_unicode_compatible
class AccessRecord(models.Model):date = models.DateField()user_count = models.IntegerField()view_count = models.IntegerField()class Meta:verbose_name = u"Access Record"verbose_name_plural = verbose_name# def __str__(self):# return "%s Access Record" % self.date.strftime('%Y-%m-%d')
admin.py
from django.contrib import admin# Register your models here.
from .models import Grades,Studentsclass StudentsInfo(admin.TabularInline):#StackeInLine显示不同 增加页面model = Studentsextra = 2class GradesAdmin(admin.ModelAdmin):inlines = [StudentsInfo]#列表页属性list_display = ['id','gname','gdate','ggirlnum','gboynum','gteacher','isDelete',]list_filter = ['gteacher']search_fields = ['gname']list_per_page = 5## #添加修改页属性# fields = ['ganame','gdate','ggirlnum','isDelete','gboynum']# fieldsets = [('num',{"fields":['ggirlnum','gboynum']}),('base',{"fields":['gname','gdate','isDelete','home','shome','sbir','sidcard','sschnum','stel']})]@admin.register(Students)
class StudentAdmin(admin.ModelAdmin):def gender(self):if self.sgender:return "女"else:return "男"#设置页面名称gender.short_description = "性别"list_display = ['pk','sname',gender,'scontend','sgrade','isDelete','shome','sbir','sidcard','sschnum','stel']#每页显示人数list_per_page = 10#按照班级筛选list_filter = ['sgrade']#查找search_fields = ['sname']#执行动作的位置actions_on_bottom = Trueactions_on_top = False#注册
# admin.site.register(Students,StudentAdmin)
admin.site.register(Grades,GradesAdmin)