# -*- coding: utf-8 -*-
from django.http import HttpResponse
from ScoreManager.models import Student
def search_subject(key):
list = []
students = {}
for student in Student.objects.all():
if key == 'chinese':
students[student] = student.chinese
list.append(student.chinese)
elif key == 'math':
students[student] = student.math
list.append(student.math)
elif key == 'english':
students[student] = student.english
list.append(student.english)
elif key == 'physics':
students[student] = student.physics
list.append(student.physics)
elif key == 'chemistry':
students[student] = student.chemistry
list.append(student.chemistry)
elif key == 'summary':
students[student] = student.summary
list.append(student.summary)
list.sort(reverse=True)
response = []
r = ""
for l in list:
for student in students.keys():
if students[student] == l:
r = student.number + " " + student.name + " " + key + ": " + str(l)
response.append(r)
return response
def search_score(key):
students = []
list = []
for student in Student.objects.all():
if student.chinese >= key and student.math >= key and student.english >= key and student.physics >= key and student.chemistry >= key:
students.append(student)
list.append(student.summary)
list.sort(reverse=True)
response = []
r = ""
for l in list:
for student in students:
if student.summary == l:
r = student.number + " " + student.name + " chinese:" + str(student.chinese) + " math:" + str(student.math) + " english:" + str(student.english) + " physics" + str(student.physics) + " chemistry:" + str(student.chemistry)+ " summary:" + str(l)
response.append(r)
return response
def search_student(key):
response = ""
for student in Student.objects.all():
if student.number == key or student.name == key:
response = student.number + " " + student.name + " chinese:" + str(student.chinese) + " math:" + str(student.math) + " english:" + str(student.english) + " physics" + str(student.physics) + " chemistry:" + str(student.chemistry)+ " summary" + str(student.summary)
return response
def add(key):
keys = key.split()
if len(keys) != 8:
return "输入信息错误"
else:
find = False
for student in Student.objects.all():
if student.number == keys[0]:
return "该学生已存在"
if not find:
student = Student(number=keys[0], name=keys[1], chinese=float(keys[2]), math=float(keys[3]), english=float(keys[4]), physics=float(keys[5]), chemistry=float(keys[6]), summary=float(keys[7]))
student.save()
return "添加信息成功"
def change(key):
keys = key.split()
if len(keys) != 8:
return "输入信息错误"
else:
find = False
for student in Student.objects.all():
if student.number == keys[0] or student.name == keys[1]:
find = True
student.number = keys[0]
student.name = keys[1]
student.chinese = float(keys[2])
student.math = float(keys[3])
student.english = float(keys[4])
student.physics = float(keys[5])
student.chemistry = float(keys[6])
student.summary = float(keys[7])
student.save()
return "修改信息成功"
if not find:
return "该学生不存在"
def delete(key):
find = False
for student in Student.objects.all():
if student.number == key or student.name == key:
find = True
student.delete()
return "删除信息成功"
if not find:
return "该学生不存在"
没有合适的资源?快使用搜索试试~ 我知道了~
一个基于Django框架的学生成绩管理系统,可进行增、删、改、查等操作。.zip
共44个文件
py:16个
pyc:15个
html:7个
需积分: 5 0 下载量 173 浏览量
2024-04-26
16:32:50
上传
评论
收藏 38KB ZIP 举报
温馨提示
django Django是一个高级的Python Web框架,可以快速开发安全和可维护的网站。由经验丰富的开发者构建,Django负责处理网站开发中麻烦的部分,可以专注于编写应用程序,而无需重新开发。它是免费和开源的,有活跃繁荣的社区,丰富的文档,以及很多免费和付费的解决方案。 [8]2019年12月2日,Django 3. 0发布 Django是高水准的Python编程语言驱动的一个开源模型.视图,控制器风格的Web应用程序框架,它起源于开源社区。使用这种架构,程序员可以方便、快捷地创建高品质、易维护、数据库驱动的应用程序。这也正是OpenStack的Horizon组件采用这种架构进行设计的主要原因。另外,在Dj ango框架中,还包含许多功能强大的第三方插件,使得Django具有较强的可扩展性 [2]。Django 项目源自一个在线新闻 Web 站点,于 2005 年以开源的形式被释放出来。Django 框架的核心组件有: 1. 2. 用于创建模型的对象关系映射; 3. 为最终用户设计较好的管理界面; 4. URL 设计; 5. 设计者友好的模板语言; 6. 缓存系统。
资源推荐
资源详情
资源评论
收起资源包目录
一个基于Django框架的学生成绩管理系统,可进行增、删、改、查等操作。.zip (44个子文件)
content
db.sqlite3 128KB
Manager
__init__.py 0B
.vs
Manager
v15
.suo 11KB
slnx.sqlite 76KB
VSWorkspaceState.json 104B
wsgi.py 392B
view.py 230B
urls.py 1KB
settings.py 3KB
__pycache__
urls.cpython-36.pyc 1KB
view.cpython-36.pyc 394B
settings.cpython-36.pyc 2KB
testdb.cpython-36.pyc 3KB
__init__.cpython-36.pyc 130B
wsgi.cpython-36.pyc 534B
search.cpython-36.pyc 824B
1160300117 132KB
templates
search_score.html 1KB
.vscode
settings.json 55B
search_subject.html 1KB
change.html 1022B
delete.html 1022B
add.html 1019B
search_student.html 1KB
manager.html 4KB
manage.py 805B
ScoreManager
__init__.py 0B
tests.py 60B
admin.py 63B
migrations
__init__.py 0B
0001_initial.py 911B
__pycache__
0001_initial.cpython-36.pyc 845B
__init__.cpython-36.pyc 146B
apps.py 99B
models.py 382B
manager.py 4KB
__pycache__
admin.cpython-36.pyc 176B
manager.cpython-36.pyc 3KB
views.cpython-36.pyc 2KB
form.cpython-36.pyc 1KB
__init__.cpython-36.pyc 135B
models.cpython-36.pyc 583B
form.py 426B
views.py 1KB
共 44 条
- 1
资源评论
生瓜蛋子
- 粉丝: 3798
- 资源: 4401
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功