Py学习  »  Python

Python学生信息管理系统(入门级可当期末作业)

python自留地 • 3 天前 • 23 次点击  

拿去当期末作业

信息管理系统源码:

长按左侧二维码 2 秒

回复「管理」即可获取源码

(非本号)

 



一、运行效果

  •  查询全部

  • 搜索

  • 添加

  • 修改

二、说明

本实例是基于Python3+Django+Sqlite实现的,Django入门级项目(主要是练习数据库的CURD),对于想要练习Django的同学来说,通过这个实例能够加深对数据库基本操作的理解

运行流程

  1. 解压

  2. 切换安装有Django的Python虚拟环境

  3. 运行命令python3 manage.py runserver

 

 

三、部分示例代码

 

# -*- coding:utf-8 -*-
from django.shortcuts import render,redirectfrom django.views.decorators.csrf import csrf_exempt
from django.conf import settings    # 获取 settings.py 里边配置的信息import osfrom .models import *
# 1.1.前往 index 页(all)defall_page(request):
    data = student_info.objects.all()    content={'data': data}return render(request, 'student/all.html', content)
# 1.2.前往 add 页defadd_page( request ):return render(request, 'student/add.html')
# 2.增@csrf_exemptdefadd_student(request):    t_name = request.POST['tName']    t_age = request.POST['tAge']    t_image = request.FILES['tImage']    fname = os.path.join(settings.MEDIA_ROOT, t_image.name)with open(fname, 'wb'as pic:for c in t_image.chunks():            pic.write(c)
    student=student_info()    student.t_name=t_name    student.t_age=t_age# 存访问路径到数据库    student.t_image = os.path.join("/static/media/", t_image.name)    student.save()
return redirect('/allPage')
来源:https://www.itprojects.cn/162.html


信息管理系统源码:

长按左侧二维码 2 秒

回复「管理」即可获取源码

(非本号)

 



   不忘编程初心,一起学习! 


加微信 python1068 带你进群一起学编程



戳原文👇纯免费,学编程~
有用就奖励个👍在看呗~

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/192496