Django 学生管理系统
1. 一对一 班级 模态增加 编辑
- def classes(request):
- data = sqlheper.get_list("select cid,title from class",[])
- return render(request, "classes.html", {"data": data})
- def motai_add_class(request):
- ret = {'status': True, 'message': None}
- title = request.POST.get('title')
- try:
- nid = request.POST.get('nid')
- content = request.POST.get('content')
- sqlheper.motify_sql('insert into class(title) values(%s)',[title,])
- except Exception as e:
- ret['status'] = False
- ret['message'] = "处理异常"
- return HttpResponse(json.dumps(ret))
- def modal_edit_class(request):
- print(request.POST)
- ret = {'status': True, 'message':None}
- try:
- id = request.POST.get('id')
- title = request.POST.get('title')
- sqlheper.motify_sql('update class set title=%s where cid=%s',[title,id,])
- except Exception as e:
- ret['status'] = False
- ret['message'] = "处理异常"
- return HttpResponse(json.dumps(ret))
classes.html
2.一对多 学生班级 模态增加 编辑
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shadow{
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: black;
- z-index: 999;
- opacity: 0.4;
- }
- .Modal{
- position: fixed;
- top: 50%;
- left: 50%;
- width: 400px;
- height: 300px;
- margin-left: -200px;
- margin-top: -150px;
- z-index: 1000;
- background-color: white;
- }
- </style>
- </head>
- <body>
- <h1>班级学员</h1>
- <div>
- <a id="addStudent">模态框增加</a>
- </div>
- <table border="1px">
- <thead>
- <tr>
- <td>学员名称</td>
- <td>学生名称</td>
- <td>班级名称</td>
- <td>模态操作</td>
- </tr>
- </thead>
- <tbody>
- {% for row in student_list %}
- <tr>
- <td>{{ row.sid }}</td>
- <td>{{ row.name }}</td>
- <td clsId="{{ row.class_id }}">{{ row.title }}</td>
- <td>
- <a class="btn-edit">编辑</a>
- <a >删除</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <div id="shadow" class="shadow hide"></div>
- {#增加#}
- <div id="addModal" class="Modal hide">
- <p>学生名称:
- <input id="add_name" type="text" name="add_name">
- </p>
- <p>学生性别:
- <input id="add_sex" type="text" name="add_sex">
- </p>
- <p>班级名称:
- <select id="add_classId" name="add_classId">
- {% for row in class_list %}
- <option value="{{ row.cid }}">{{ row.title }}</option>
- {% endfor %}
- </select>
- </p>
- <input id="btnAdd" type="button" value="提交"><span id="addError"></span>
- <input id="btnCancle" type="button" value="取消">
- </div>
- {#编辑#}
- <div id="editModal" class="Modal hide">
- <h3>编辑学生信息</h3>
- <p>
- 姓名:<input id="editName" type="text" name="name" placeholder="姓名" />
- <input type="text" id="editId" style="display: none" />
- </p>
- <p>
- 班级:
- <select id="editClassId" name="classId">
- {% for row in class_list %}
- <option value="{{ row.cid }}">{{ row.title }}</option>
- {% endfor %}
- </select>
- </p>
- <input id="btnEdit" type="button" value="更新" />
- <span id="editError" style="color: red;"></span>
- <input id="btnCancle" type="button" value="取消" />
- </div>
- <script src="/static/jquery-3.2.1.js"></script>
- <script>
- $(function () {
- {# 增加#}
- $("#addStudent").click(function () {
- $("#shadow,#addModal").removeClass("hide");
- });
- $("#btnCancle").click(function () {
- $("#shadow,#addModal").addClass("hide");
- $("#editModal").addClass("hide");
- });
- $("#btnAdd").click(function () {
- var add_name=$("#add_name").val();
- var add_age=$("#add_sex").val();
- var add_classId=$("#add_classId").val();
- $.ajax({
- url:"/motai_add_student/",
- type:"POST",
- data:{"add_name":add_name,"add_age":add_age,"add_classId":add_classId},
- success:function (arg) {
- arg = JSON.parse(arg);
- if (arg.status){
- location.reload();
- }else {
- $("#addError").text(arg.message);
- }
- }
- })
- });
- {# 编辑 #}
- $('.btn-edit').click(function(){
- $('#shadow,#editModal').removeClass('hide');
- var tds = $(this).parent().prevAll();
- var studentId = $(tds[2]).text();
- var studentName = $(tds[1]).text();
- var classId = $(tds[0]).attr('clsid');
- console.log(studentId,studentName,classId);
- $('#editId').val(studentId);
- $('#editName').val(studentName);
- $('#editClassId').val(classId);
- });
- $('#btnEdit').click(function(){
- $.ajax({
- url:'/motai_edit_student/',
- type: 'POST',
- data: {'sid': $('#editId').val(), 'name':$('#editName').val(),'class_id': $('#editClassId').val()},
- dataType: 'JSON', //JSON.parse(arg)
- success:function(arg){
- if(arg.status){
- location.reload();
- }else{
- $('#editError').text(arg.message);
- }
- }
- })
- });
- })
- </script>
- </body>
- </html>
student.html
- def student(request):
- student_list = sqlheper.get_list("select student.sid,student.name,student.class_id,class.title from student left join class on student.class_id=class.cid",[])
- class_list = sqlheper.get_list("select cid,title from class",[])
- return render(request, "student.html", {"student_list":student_list, "class_list":class_list})
- def motai_add_student(request):
- print(request.POST)
- ret = {"status":True,"message":None}
- try:
- name = request.POST.get("add_name")
- age = request.POST.get("add_age")
- classId = request.POST.get("add_classId")
- sqlheper.motify_sql("insert into student(name,age,class_id) values(%s,%s,%s)",[name,age,classId,])
- except Exception as e:
- ret["status"] = False
- ret["message"] = str(e)
- return HttpResponse(json.dumps(ret))
- def motai_edit_student(request):
- ret = {'status': True,'message': None}
- try:
- print(request.POST)
- sid = request.POST.get('sid')
- name = request.POST.get('name')
- class_id = request.POST.get('class_id')
- sqlheper.motify_sql('update student set name=%s,class_id=%s where sid=%s',[name,class_id,sid,])
- except Exception as e:
- ret['status'] = False
- ret['message'] = str(e)
- return HttpResponse(json.dumps(ret))
Views
3.多对多 老师 班级 模态增加 编辑
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shadow{
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: black;
- z-index: 999;
- opacity: 0.4;
- }
- .Modal{
- position: fixed;
- top: 50%;
- left: 50%;
- width: 400px;
- height: 300px;
- margin-left: -200px;
- margin-top: -150px;
- z-index: 1000;
- background-color: white;
- }
- </style>
- </head>
- <body>
- <h1>老师 班级管理</h1>
- <div>
- <a id="addModal">模态框增加</a>
- </div>
- <table border="solid" >
- <thead>
- <tr>
- <td>ID</td>
- <td>老师名称</td>
- <td>班级名称</td>
- <td>操作</td>
- </tr>
- </thead>
- <tbody>
- {% for row in teacher_list %}
- <tr>
- <td>{{ row.tid }}</td>
- <td>{{ row.name }}</td>
- <td>
- {% for item in row.titles %}
- {{ item }}
- {% endfor %}
- </td>
- <td>
- <a class="editModal">编辑</a>
- <a class="delModal">删除</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <div id="shadow" class="shadow hide"></div>
- <div id="add_tea_cls" class="Modal hide">
- <p>老师名称:
- <input id="add_name" type="text" name="add_name">
- </p>
- <p>班级名称:
- <select id="add_classId" name="add_classId" multiple>
- {% for row in class_list %}
- <option value="{{ row.cid }}">{{ row.title }}</option>
- {% endfor %}
- </select>
- </p>
- <input id="btnAdd" type="button" value="提交"><span id="addError"></span>
- <input id="btnCancle" type="button" value="取消">
- </div>
- <div id="edit_tea_cls" class="Modal hide">
- <p>老师名称:
- <input id="add_name" type="text" name="add_name">
- </p>
- <p>班级名称:
- <select id="add_classId" name="add_classId" multiple>
- {% for row in class_list %}
- <option value="{{ row.cid }}">{{ row.title }}</option>
- {% endfor %}
- </select>
- </p>
- <input id="btnEdit" type="button" value="提交"><span id="addError"></span>
- <input id="cacleEdit" type="button" value="取消">
- </div>
- <script src="/static/jquery-3.2.1.js"></script>
- <script>
- $(function () {
- {# 增加#}
- $("#addModal").click(function () {
- $("#shadow,#add_tea_cls").removeClass("hide");
- });
- $("#btnCancle").click(function () {
- $("#shadow,#add_tea_cls").addClass("hide");
- });
- $("#btnAdd").click(function () {
- tname=$("#add_name").val();
- class_list=$("#add_classId").val();
- console.log(class_list)
- $.ajax({
- url:"/new_teacher/",
- type:"POST",
- data:{"tname":tname,"class_list":class_list},
- success:function (arg) {
- arg = JSON.parse(arg);
- if (arg.status){
- location.reload();
- }else {
- $("#addError").text(arg.message);
- }
- }
- })
- });
- {# 编辑#}
- $(".editModal").click(function () {
- $("#shadow").removeClass("hide");
- $("#edit_tea_cls").removeClass("hide");
- });
- $("#cacleEdit").click(function () {
- $("#shadow,#edit_tea_cls").addClass("hide");
- });
- })
- </script>
- </body>
- </html>
teacher.html
- def teacher(request):
- teacher_list=sqlheper.get_list("""
- select teacher.tid as tid,teacher.name,class.title from teacher
- left join teacher_class on teacher_class.teacher_id=teacher.tid
- left join class on class.cid=teacher_class.class_id""",[])
- # print(teacher_list)
- result = {}
- for row in teacher_list:
- tid = row["tid"]
- if tid in result:
- result[tid]["titles"].append(row["title"])
- else:
- result[tid] = {"tid":row["tid"],"name":row["name"],"titles":[row["title"],]}
- class_list = sqlheper.get_list("select cid,title from class",[])
- return render(request, "teacher.html_模态增加 老师班级", {"teacher_list":result.values(), "class_list":class_list})
- ###模态增加
- def new_teacher(request):
- print(request.POST)
- ret = {'status': True, 'message': None}
- try:
- class_list=request.POST.getlist("class_list[]")
- tname=request.POST.get("tname")
- print(class_list)
- print(tname)
- teacher_id=sqlheper.get_IncrementId("insert into teacher(name) values(%s)",[tname,])
- for item in class_list:
- sqlheper.motify_sql("insert into teacher_class(teacher_id,class_id) values(%s,%s)",[teacher_id,item,])
- except Exception as e:
- ret['status'] = False
- ret['message'] = str(e)
- return HttpResponse(json.dumps(ret))
views
4.多对多 老师 班级 新url 增加 编辑
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1>老师 班级管理</h1>
- <div>
- <a href="/add_page_teacher/">增加</a>
- </div>
- <table border="solid" >
- <thead>
- <tr>
- <td>ID</td>
- <td>老师名称</td>
- <td>班级名称</td>
- <td>操作</td>
- </tr>
- </thead>
- <tbody>
- {% for row in teacher_list %}
- <tr>
- <td>{{ row.tid }}</td>
- <td>{{ row.name }}</td>
- <td>
- {% for item in row.titles %}
- {{ item }}
- {% endfor %}
- </td>
- <td>
- <a href="/edit_page_teacher/?tid={{ row.tid }}">编辑</a>
- <a >删除</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </body>
- </html>
teacher.html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h1>增加老师</h1>
- <form action="/add_teacher/" method="POST">
- <p>老师名称: <input type="text" name="name"></p>
- <input type="submit">
- </form>
- </body>
- </html>
add_page.teacher
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <h3>编辑老师班级</h3>
- <form action="/edit_page_teacher/?tnid={{ tname.tid }}" method="post">
- <p>老师名称:<input type="text" name="name" value="{{ tname.name }}"></p>
- <p>班级名称:
- <select name="class_ids" multiple size="">
- {% for item in class_list %}
- {% if item.cid in class_ids %}
- <option selected value="{{ item.cid }}">{{ item.title }}</option>
- {% else %}
- <option value="{{ item.cid }}">{{ item.title }}</option>
- {% endif %}
- {% endfor %}
- </select>
- <p><input type="submit" value="提交"></p>
- </p>
- </form>
- </body>
- </html>
edit_teacher
- ###网页显示
- def teacher(request):
- teacher_list=sqlheper.get_list("""
- select teacher.tid as tid,teacher.name,class.title from teacher
- left join teacher_class on teacher_class.teacher_id=teacher.tid
- left join class on class.cid=teacher_class.class_id""",[])
- # print(teacher_list)
- result = {}
- for row in teacher_list:
- tid = row["tid"]
- if tid in result:
- result[tid]["titles"].append(row["title"])
- else:
- result[tid] = {"tid":row["tid"],"name":row["name"],"titles":[row["title"],]}
- class_list = sqlheper.get_list("select cid,title from class",[])
- return render(request, "teacher.html", {"teacher_list":result.values(), "class_list":class_list})
- ###网页增加
- def add_page_teacher(request):
- if request.method=="GET":
- obj = sqlheper.SqlHelper()
- class_list = obj.get_list("select cid,title from class",[])
- obj.close()
- return render(request,"add_page_teacher.html",{"class_list":class_list})
- else:
- name = request.POST.get("name")
- obj = sqlheper.SqlHelper()
- teacher_id = obj.get_lastrowid("insert into teacher(name) values(%s)",[name,])
- obj.close()
- class_ids = request.POST.getlist("class_ids")
- print(class_ids)
- data_list = []
- for cls_id in class_ids:
- temp = (teacher_id, cls_id,)
- data_list.append(temp)
- obj = sqlheper.SqlHelper()
- obj.multiple_modify('insert into teacher_class(teacher_id,class_id) values(%s,%s)', data_list)
- obj.close()
- return redirect('/teacher/')
- ###网页编辑
- def edit_page_teacher(request):
- if request.method=="GET":
- teacher_id = request.GET.get("tid")
- obj = sqlheper.SqlHelper()
- tname = obj.get_one("select tid,name from teacher where tid=%s",[teacher_id,])
- class_list = obj.get_list("select cid,title from class",[])
- class_ids = obj.get_list("select class_id from teacher_class where teacher_id =%s",[teacher_id,])
- obj.close()
- temp = []
- for i in class_ids:
- temp.append(i['class_id'])
- return render(request,"edit_page_teacher.html",{
- "tname":tname,
- "class_list":class_list,
- "class_ids":temp,
- })
- else:
- tid=request.GET.get("tnid")
- name=request.POST.get("name")
- class_ids=request.POST.getlist("class_ids")
- obj = sqlheper.SqlHelper()
- obj.modify("update teacher set name=%s where tid=%s",[name,tid,])
- obj.modify('delete from teacher_class where teacher_id=%s',[tid,])
- data_list = []
- for cls_id in class_ids:
- temp = (tid,cls_id)
- data_list.append(temp)
- obj.multiple_modify('insert into teacher_class(teacher_id,class_id) values(%s,%s)',data_list)
- obj.close()
- return redirect('/teacher/')
views
5.多对多 老师 班级 模态 增加 编辑
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .hide{
- display: none;
- }
- .shadow{
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: black;
- z-index: 999;
- opacity: 0.4;
- }
- .loading{
- position: fixed;
- width: 32px;
- height: 32px;
- left: 50%;
- top:50%;
- margin-left: -16px;
- margin-top: -16px;
- background-color: rebeccapurple;
- background-image: url("/static/images/loading.gif") ;
- background-size: 100%;
- }
- .Modal{
- position: fixed;
- top: 50%;
- left: 50%;
- width: 400px;
- height: 300px;
- margin-left: -200px;
- margin-top: -150px;
- z-index: 1000;
- background-color: white;
- }
- </style>
- <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
- <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.css">
- </head>
- <body>
- <h1 >老师 班级管理</h1>
- <div class="btn btn-success">
- <a id="addModal">模态框增加</a>
- </div>
- <table border="solid" class="table table-striped">
- <thead>
- <tr>
- <td>ID</td>
- <td>老师名称</td>
- <td>班级名称</td>
- <td>操作</td>
- </tr>
- </thead>
- <tbody>
- {% for row in teacher_list %}
- <tr>
- <td>{{ row.tid }}</td>
- <td>{{ row.name }}</td>
- <td>
- {% for item in row.titles %}
- {{ item }}
- {% endfor %}
- </td>
- <td>
- <a class="editModal">编辑</a>
- <a class="delModal">删除</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <div id="shadow" class="shadow hide"></div>
- <div id="loading" class="loading hide"></div>
- <div id="add_tea_cls" class="Modal hide">
- <p>老师名称:
- <input id="add_name" type="text" name="add_name">
- </p>
- <p>班级名称:
- <select id="add_classId" name="add_classId" multiple size="">
- </select>
- </p>
- <input id="btnAdd" type="button" value="提交"><span id="addError"></span>
- <input id="btnCancle" type="button" value="取消">
- </div>
- <div id="edit_tea_cls" class="Modal hide">
- <input type="text" id="hide_id" style="display: none">
- <p>老师名称:
- <input id="edit_name" type="text" name="add_name">
- </p>
- <p>班级名称:
- <select id="edit_classId" name="edit_classId" multiple size="">
- </select>
- </p>
- <input id="btnEdit" type="button" value="提交"><span id="addError"></span>
- <input id="cacleEdit" type="button" value="取消">
- </div>
- <script src="/static/jquery-3.2.1.js"></script>
- <script>
- $(function () {
- {# 增加#}
- $("#addModal").click(function () {
- $("#shadow,#loading").removeClass("hide");
- $.ajax({
- url:"/get_all_class/",
- type:"GET",
- dataType:"JSON",
- success:function (arg) {
- $.each(arg,function (i,row) {
- var tag = $("<option>"); /*var tag = document.createElement('option');*/
- tag.text(row.title); /*tag.innerHTML = row.title;*/
- tag.prop("value",row.cid);
- $("#add_classId").append(tag); /*tag.setAttribute('value',row.id);*/
- });
- $('#loading').addClass('hide');
- $('#add_tea_cls').removeClass('hide');
- }
- })
- });
- $("#btnCancle").click(function () {
- $("#shadow,#add_tea_cls").addClass("hide");
- });
- $("#btnAdd").click(function () {
- var tname=$("#add_name").val();
- var class_list=$("#add_classId").val();
- console.log(class_list);
- $.ajax({
- url:"/new_teacher/",
- type:"POST",
- data:{"tname":tname,"class_list":class_list},
- dataType:"JSON",
- traditional: true, // 如果提交的数据的值有列表,则需要添加此属性
- success:function (arg) {
- if (arg.status){
- location.reload();
- }else {
- alert(arg.message);
- }
- }
- })
- });
- {# 编辑#}
- $(".editModal").click(function () {
- $("#shadow,#loading").removeClass("hide");
- var ids=$(this).parent().prevAll()[2];
- var id=$(ids).text();
- $("#hide_id").val(id);
- $.ajax({
- url: "/edit_tea_cls/",
- type: "POST",
- dataType: "JSON",
- data:{"id":id},
- success: function (arg) {
- class_list = arg[0];
- teacher_info = arg[1];
- class_lds = arg[2];
- console.log(class_lds);
- $("#edit_classId").empty();
- $.each(class_list, function (i, row) {
- var tag = $("<option>");
- tag.text(row.title);
- tag.prop("value", row.cid);
- if(class_lds.indexOf(row.cid) == -1){
- $("#edit_classId").append(tag);
- }else {
- tag.prop("selected","selected");
- $("#edit_classId").append(tag);
- }
- });
- $("#edit_name").val(teacher_info["name"]);
- $('#loading').addClass('hide');
- $('#edit_tea_cls').removeClass('hide');
- }
- });
- $("#cacleEdit").click(function () {
- $("#shadow,#edit_tea_cls").addClass("hide");
- });
- })
- {# 编辑提交#}
- $("#btnEdit").click(function () {
- var tid= $("#hide_id").val();
- var name = $("#edit_name").val();
- var class_ids = $("#edit_classId").val();
- $.ajax({
- url:"/modal_edit_teacher/",
- type:"post",
- dataType:"JSON",
- traditional:true,
- data:{"tid":tid,"name":name,"del_class_id":del_class_id},
- $.ajax({
- url:"/modal_edit_teacher/",
- type:"post",
- dataType:"JSON",
- traditional:true,
- data:{"tid":tid,"name":name,"class_ids":class_ids},
- success:function (arg) {
- if (arg.status){
- location.reload();
- }else {
- alert("")
- }
- }
- })
- })
- })
- })
- </script>
- </body>
- </html>
teacher.html
- #显示
- def teacher(request):
- tk = request.COOKIES.get("ticket")
- if not tk:
- return redirect("/login/")
- teacher_list=sqlheper.get_list("""
- select teacher.tid as tid,teacher.name,class.title from teacher
- left join teacher_class on teacher_class.teacher_id=teacher.tid
- left join class on class.cid=teacher_class.class_id""",[])
- # print(teacher_list)
- result = {}
- for row in teacher_list:
- tid = row["tid"]
- if tid in result:
- result[tid]["titles"].append(row["title"])
- else:
- result[tid] = {"tid":row["tid"],"name":row["name"],"titles":[row["title"],]}
- return render(request, "teacher.html", {"teacher_list":result.values()})
- #增加
- def get_all_class(request):
- import time
- time.sleep(1)
- obj = sqlheper.SqlHelper()
- class_list = obj.get_list('select cid,title from class',[])
- obj.close()
- return HttpResponse(json.dumps(class_list))
- def new_teacher(request):
- ret = {'status': True, 'message': None}
- try:
- class_list=request.POST.getlist("class_list")
- tname=request.POST.get("tname")
- teacher_id=sqlheper.get_IncrementId("insert into teacher(name) values(%s)",[tname,])
- data_list = []
- for cls_id in class_list:
- temp = (teacher_id,cls_id,)
- data_list.append(temp)
- obj = sqlheper.SqlHelper()
- obj.multiple_modify('insert into teacher_class(teacher_id,class_id) values(%s,%s)', data_list)
- obj.close()
- except Exception as e:
- ret['status'] = False
- ret['message'] = str(e)
- return HttpResponse(json.dumps(ret))
- #编辑
- def edit_tea_cls(request):
- id = request.POST.get("id")
- obj = sqlheper.SqlHelper()
- class_list = obj.get_list('select cid,title from class',[])
- teacher_info = obj.get_one("select tid,name from teacher where tid=%s",[id,])
- class_id = obj.get_list("select class_id from teacher_class where teacher_id=%s",[id,])
- data_list = []
- for cls_id in class_id:
- data_list.append(cls_id["class_id"])
- print(teacher_info)
- total = []
- total.append(class_list)
- total.append(teacher_info)
- total.append(data_list)
- obj.close()
- return HttpResponse(json.dumps(total))
- def modal_edit_teacher(request):
- ret = {'status': True, 'message': None}
- try:
- name = request.POST.get("name")
- tid = request.POST.get("tid")
- class_ids = request.POST.getlist("class_ids")
- obj = sqlheper.SqlHelper()
- obj.modify("update teacher set name=%s where tid=%s", [name, tid, ])
- obj.modify('delete from teacher_class where teacher_id=%s', [tid, ])
- data_list = []
- for cls_id in class_ids:
- temp = (tid, cls_id)
- data_list.append(temp)
- obj.multiple_modify('insert into teacher_class(teacher_id,class_id) values(%s,%s)', data_list)
- obj.close()
- except Exception as e:
- ret['status'] = False
- ret['message'] = str(e)
- return HttpResponse(json.dumps(ret))
views
Django 学生管理系统的更多相关文章
- 饮冰三年-人工智能-Python-26 Django 学生管理系统
背景:创建一个简单的学生管理系统,熟悉增删改查操作 一:创建一个Django项目(http://www.cnblogs.com/wupeiqi/articles/6216618.html) 1:创建实 ...
- Django学生管理系统添加学生时,报错Not Found: /POST
最近在学习Django,跟着视频写了一个学生系统,主要是增删改查操作,界面丑的一匹 1.url.py from django.contrib import admin from django.urls ...
- python Django学生管理
Django 学生管理系统 1. 一对一 班级 模态增加 编辑 <!DOCTYPE html> <html lang="en"> <head> ...
- ORM版,学生管理系统02
学生管理系统 urls.py url(r'^student_list/$',views.student_list,name="student_list"), url(r'^dele ...
- 基于BootStrap,FortAweSome,Ajax的学生管理系统
一. 基于BootStrap,FortAweSome,Ajax的学生管理系统代码部分 1.students.html <1>html页面文件 <!DOCTYPE html> & ...
- Django_学生管理系统
一. Django简易学生管理系统 1.在pycharm中创建工程student_manage_system,添加app:student_manage 2.配置静态文件:在工程项目目录下新建目录sta ...
- 【IOS开发笔记02】学生管理系统
端到端的机会 虽然现在身处大公司,但是因为是内部创业团队,产品.native.前端.服务器端全部坐在一起开发,大家很容易做零距离交流,也因为最近内部有一个前端要转岗过来,于是手里的前端任务好像可以抛一 ...
- C程序范例(2)——学生管理系统”链表“实现
1.对于学生管理系统,能够实现的方法有许多,但是今天我们用链表的方法来实现.虽然初学者很可能看不懂,但是不要紧,这是要在整体的系统的学习完C语言之后,我才编写出的程序.所以大家不必要担心.在这里与大家 ...
- jsp学习之基于mvc学生管理系统的编写
mvc开发模式:分别是 model层 view层 Control层 在学生管理系统中,model层有学生实体类,数据访问的dao层,view层主要是用于显示信息的界面,Control层主要是servl ...
随机推荐
- 一步步教你开发、部署第一个去中心化应用(Dapp) - 宠物商店
今天我们来编写一个完整的去中心化(区块链)应用(Dapps), 本文可以和编写智能合约结合起来看. 写在前面 阅读本文前,你应该对以太坊.智能合约有所了解,如果你还不了解,建议你先看以太坊是什么除此之 ...
- 用session做权限控制
一个需要用户进行登录的网站,基本上都会设置用户权限,对不同的用户进行权限控制.例如:一个网站肯定会有一个管理员管理着普通的用户,普通的用户不可能对其他用户有着类似于增删改查等操作,这样网站都乱了--, ...
- Mycat 分片规则详解--范围取模分片
实现方式:该算法先进行范围分片,计算出分片组,组内在取模 优点:综合了范围分片和取模分片的优点,分片组内使用取模可以保证组内的数据分布比较均匀,分片组之间采用范围分片可以兼顾范围分片的特点,事先规划好 ...
- MYSQL数据库学习五 表的操作和约束
5.1 表的基本概念 表示包含数据库中所有数据的数据库对象.一行代表唯一的记录,一列代表记录的一个字段. 列(Columns):属性列,创建表时必须指定列名和数据类型. 索引(Indexes):根据指 ...
- 【Linux】 文本比较工具 diff和cmp
Linux 文本比较工具 ■ diff命令 diff用于逐行比较两个文本文件,列出其不同之处 diff [option] <file1> <file2> file1和file2 ...
- 如何使用 RESTClient 调试微信支付接口
我们知道微信支付使用http协议进行api调用,body 使用xml格式,使用的一般http在线调试工具,无法进行xml数据的post. RESTClient 做的很好,支持各种http 方法,bod ...
- 2017-2018-1 Java演绎法 第一周 作业
团队学习:<构建之法> [团队成员]: 学号 姓名 负责工作 20162315 马军 日常统计,项目部分代码 20162316 刘诚昊 项目部分代码,代码质量测试 20162317 袁逸灏 ...
- VS2005 与虚拟机的那点事
好不容易把VS2008装上了,每次F5编译的时候,程序自动退出,意外的是VS2005也是同样的结果.好在有像我一样的好心人,愿意把解决的方法与大家共享. 经过搜索找到了答案,原来是VMwa ...
- 团队作业7——第二次项目冲刺(Beta版本12.05-12.07)
1.当天站立式会议照片 本次会议内容:1:每个人汇报自己完成的工作.2:组长分配各自要完成的任务. 2.每个人的工作 黄进勇:项目整合,后台代码. 李勇:前台界面优化. 何忠鹏:数据库模块. 郑希彬: ...
- Python 单向循环链表
操作 is_empty() 判断链表是否为空 length() 返回链表的长度 travel() 遍历 add(item) 在头部添加一个节点 append(item) 在尾部添加一个节点 inser ...