下载资源后端资源详情
学生管理系统.zip
大小:1.16MB
价格:38积分
下载量:0
评分:
5.0
上传者:weixin_45971950
更新日期:2025-09-22

基于python开发的简单的学生管理系统

资源文件列表(大概)

文件名
大小
Djangotest/.idea/
-
Djangotest/.idea/.gitignore
184B
Djangotest/.idea/Djangotest.iml
1.11KB
Djangotest/.idea/inspectionProfiles/
-
Djangotest/.idea/inspectionProfiles/profiles_settings.xml
174B
Djangotest/.idea/inspectionProfiles/Project_Default.xml
543B
Djangotest/.idea/misc.xml
307B
Djangotest/.idea/modules.xml
279B
Djangotest/.idea/workspace.xml
12.68KB
Djangotest/app/
-
Djangotest/app/__init__.py
-
Djangotest/app/__pycache__/
-
Djangotest/app/__pycache__/__init__.cpython-38.pyc
120B
Djangotest/app/__pycache__/admin.cpython-38.pyc
702B
Djangotest/app/__pycache__/apps.cpython-38.pyc
380B
Djangotest/app/__pycache__/models.cpython-38.pyc
915B
Djangotest/app/__pycache__/urls.cpython-38.pyc
633B
Djangotest/app/__pycache__/views.cpython-38.pyc
4.18KB
Djangotest/app/admin.py
427B
Djangotest/app/apps.py
144B
Djangotest/app/migrations/
-
Djangotest/app/migrations/__init__.py
-
Djangotest/app/migrations/__pycache__/
-
Djangotest/app/migrations/__pycache__/__init__.cpython-38.pyc
131B
Djangotest/app/migrations/__pycache__/0001_initial.cpython-38.pyc
945B
Djangotest/app/migrations/0001_initial.py
1.22KB
Djangotest/app/models.py
865B
Djangotest/app/templates/
-
Djangotest/app/templates/add.html
1.93KB
Djangotest/app/templates/delete.html
1.82KB
Djangotest/app/templates/home.html
544B
Djangotest/app/templates/info.html
979B
Djangotest/app/templates/login.html
1.69KB
Djangotest/app/templates/select.html
1.87KB
Djangotest/app/templates/update.html
1.81KB
Djangotest/app/templates/welcome.html
1.32KB
Djangotest/app/tests.py
63B
Djangotest/app/urls.py
554B
Djangotest/app/views.py
8KB
Djangotest/db.sqlite3
136KB
Djangotest/Djangotest/
-
Djangotest/Djangotest/__init__.py
60B
Djangotest/Djangotest/__pycache__/
-
Djangotest/Djangotest/__pycache__/__init__.cpython-38.pyc
185B
Djangotest/Djangotest/__pycache__/settings.cpython-38.pyc
2.48KB
Djangotest/Djangotest/__pycache__/urls.cpython-38.pyc
951B
Djangotest/Djangotest/__pycache__/wsgi.cpython-38.pyc
536B
Djangotest/Djangotest/asgi.py
413B
Djangotest/Djangotest/settings.py
3.57KB
Djangotest/Djangotest/urls.py
818B
Djangotest/Djangotest/wsgi.py
413B
Djangotest/manage.py
688B
Djangotest/static/
-
Djangotest/static/1.jpg
25.02KB
Djangotest/static/2.jpg
1.15MB
Djangotest/templates/
-

资源内容介绍

设置了0积分下载,欢迎下载学习Django的小试牛刀
from django.shortcuts import renderfrom django.http import HttpResponsefrom . import models# Create your views here.def home(request): return render(request, "home.html")LoginId = 0def login(request): #判断请求类型 if request.method =="GET": return render(request, "login.html") else: #从前端表单中获取输入的数据,即账号和密码 name = request.POST.get("username", None) pwd = request.POST.get("password", None) #获取数据库中的账号密码数据 emp = models.UserInfo.objects.values("username", "password", "UserId").filter(username=name) #判断根据账号筛选前端输入的数据是否存在于数据库中 if emp.count() == 0: return render(request, "login.html", {"msg": "登录失败,账号不存在"}) else: if emp[0]['password'] == pwd: globals()["LoginId"] = emp[0]['UserId'] return render(request, "welcome.html") else: return render(request, "login.html", {'msg': '登陆失败,密码错误'})def welcome(request): return render(request, 'welcome.html')'''def add(request): list = ['id', 'stuname', 'stuphone', 'stuaddress', 'stucollege', 'stumajor'] info = [] for li in list: info.append(request.POST.get(li)) print(info) if globals()["LoginId"] != 1: return HttpResponse('非ROOT权限,无权修改') emp = models.StuInfo.objects.filter(id=(info[0])) if emp.count() != 0: return render(request, 'add.html', {'msg': '该员工已经存在'}) models.StuInfo.objects.create(id=(info[0]), stuname=info[1], stuphone=info[2], stuaddress=info[3], stucollege=info[4], stumajor=info[5]) return render(request, 'add.html', {'msg': 'hello'})def add(request): msg = '' if request.method == 'POST': id = request.POST.get('id') stuname = request.POST.get('stuname') stuphone = request.POST.get('stuphone') stuaddress = request.POST.get('stuaddress') stucollege = request.POST.get('stucollege') stumajor = request.POST.get('stumajor') stu = models.StuInfo() stu.id = id stu.stuname = stuname stu.stuphone = stuphone stu.stuaddress = stuaddress stu.stucollege = stucollege stu.stumajor = stumajor stu.save() msg = 'success' return render(request, 'add.html', {msg: 'msg'})def add(request): if request.method=='GET': return render(request, 'add.html') elif request.method == 'POST': id = request.POST.get('id') stuname = request.POST.get('stuname') stuphone = request.POST.get('stuphone') stuaddress = request.POST.get('stuaddress') stucollege = request.POST.get('stucollege') stumajor = request.POST.get('stumajor') stu = models.StuInfo() stu.id = id stu.stuname = stuname stu.stuphone = stuphone stu.stuaddress = stuaddress stu.stucollege = stucollege stu.stumajor = stumajor stu.save() return render(request, 'add.html', {'result': '学生信息添加成功!'})'''def add(request): if request.method == 'GET': return render(request, 'add.html') elif request.method =='POST': list = ['id', 'stuname', 'stuphone', 'stuaddress', 'stucollege', 'stumajor'] info = [] for li in list: info.append(request.POST.get(li)) if globals()['LoginId'] != 1: return HttpResponse("非root用户,没有权限添加用户!") s = models.StuInfo.objects.filter(id=info[0]) print(s.count()) #判断是否已存在重复的数据 if len(s) != 0: return render(request, 'add.html', {'err': '学生信息已存在,请勿重复添加'}) stu = models.StuInfo() stu.id = info[0] stu.stuname = info[1] stu.stuphone = info[2] stu.stuaddress = info[3] stu.stucollege = info[4] stu.stumajor = info[5] stu.save() #保存数据 return render(request, 'add.html', {'success': '学生信息添加成功!!'})'''def delete(request): if request.method == 'GET': return render(request, 'delete.html') else: id = request.POST.get('id', None) stu = models.StuInfo.objects.filter(id=id) print("==", stu) if stu.count == 0: return render(request, 'delete.html', {'err': '删除失败,没有此学生信息'}) else: models.StuInfo.objects.filter(id=id).delete() return render(request, 'delete.html', {'success': '删除成功'})'''def delete(request): info = models.StuInfo.objects.all() if request.method == 'GET': return render(request, 'delete.html', {'info': info}) if globals()['LoginId'] != 1: return render(request, 'delete.html', {'err': '非root用户登录,无权删除!'}) id = request.POST.get('id', None) # print(id) if id.isspace() == True: return render(request, 'delete.html', {'err': '学号不能由空格组成,请重新输入!!!'}) if len(id) == 0: return render(request, 'delete.html', {'err': '学号不能为空,请重新输入!!!'}) emp = models.StuInfo.objects.filter(id=id) if emp.count() == 0: return render(request, 'delete.html', {'err': '该用户不存在,请重新输入!!!'}) if globals()['LoginId'] != 1: return render(request, 'delete.html', {'err': '权限不够,请用 root 账号登录'}) models.StuInfo.objects.filter(id=id).delete() return render(request, 'delete.html', {'info': info, 'success': '删除成功'})def update(request): if request.method =='GET': return render(request, 'update.html') list = ['id', 'stuname', 'stuphone', 'stuaddress', 'stucollege', 'stumajor'] info = [] for li in list: info.append(request.POST.get(li)) if globals()['LoginId'] != 1: return render(request, 'update.html', {'err': '权限不够,请切换为 root 用户重试'}) id = request.POST.get('id', None) if id.isspace() == True: return render(request, 'update.html', {'err': '学号不能为空格组成,请重新输入!'}) s = models.StuInfo.objects.filter(id=info[0]) if s.count() == 0: return render(request, 'update.html', {'err': '没有此学生信息,无法修改'}) stu = models.StuInfo() stu.id = info[0] stu.stuname = info[1] stu.stuphone = info[2] stu.stuaddress = info[3] stu.stucollege = info[4] stu.stumajor = info[5] stu.save() return render(request, 'update.html', {'success': '学生信息修改成功!'})def select(request): if request.method =='GET': return render(request, 'select.html') if globals()['LoginId'] != 1: return render(request, 'select.html', {'error': '非 root 用户,无法查看!点击重新登录!'}) #从表单中获取id值 id = request.POST.get('id', None) #判断id不能为空的字符串类型 if id.isspace() == True: return render(request, 'select.html', {'err': "不能为空值,请重新输入!"}) #从数据库根据id值将对应信息赋值给stu stu = models.StuInfo.objects.filter(id=id) if stu.count() == 0: return render(request, 'select.html', {'err': '没有查询到此学生信息,请确定是否录入系统'}) info = models.StuInfo.objects.values('id', 'stuname', 'stuphone', 'stuaddress', 'stucollege', 'stumajor').filter(id=id)[0] print("info=", info) return render(request, 'select.html', info)def info(request): if requ

用户评论 (0)

发表评论

captcha