信息管理系统源码:
长按左侧二维码 2 秒
回复「管理」即可获取源码
(非本号)
查询全部
搜索
添加
修改
本实例是基于Python3+Django+Sqlite实现的,Django入门级项目(主要是练习数据库的CURD),对于想要练习Django的同学来说,通过这个实例能够加深对数据库基本 *** 作的理解
运行流程解压
切换安装有Django的Python虚拟环境
运行命令python3 manage.py runserver
# -*- coding:utf-8 -*- from django.shortcuts import render,redirect from django.views.decorators.csrf import csrf_exempt from django.conf import settings # 获取 settings.py 里边配置的信息 import os from .models import * # 1.1.前往 index 页(all) def all_page(request): data = student_info.objects.all() content={'data': data} return render(request, 'student/all.html', content) # 1.2.前往 add 页 def add_page( request ): return render(request, 'student/add.html') # 2.增 @csrf_exempt def add_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 秒
回复「管理」即可获取源码
(非本号)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)