Django (二)使用 JQuery、Ajax

Stella981
• 阅读 805

一、作业内容
1、班级表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用JQuery、Ajax实现。
2、学生表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用Jquery、Ajax实现。
3、教师表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用Jquery、Ajax实现。


1、班级表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用JQuery、Ajax实现。

Django (二)使用 JQuery、Ajax
Django (二)使用 JQuery、Ajax
Django (二)使用 JQuery、Ajax

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>班级列表</title>
{
   
   
   #    <link rel="stylesheet" href="https://my.oschina.net/static/bootstrap-3.3.7-dist/css/bootstrap.css">#}
{
   
   
   #    <link rel="stylesheet" href="https://my.oschina.net/static/font-awesome-4.7.0/css/font-awesome.css">#}
    <link rel="stylesheet" href="/static/common.css">
</head>
<body>
<h3>班级列表</h3>
<div><a id="openAddModal">添加</a></div>
<table border="1" cellspacing="0">
    <thead>
        <th>ID</th>
        <th>班级名称</th>
        <th>操作</th>
    </thead>
    <tbody>
        {
   
   
   % for item in result %}
            <tr>
                <td>{
   
   
   {
   
   
   item.id}}</td>
                <td>{
   
   
   {
   
   
   item.title}}</td>
                <td>
                    <a class="openEditModal">编辑</a>
                    |
                    <a class="btnDel">删除</a>
                </td>
            </tr>
        {
   
   
   % endfor %}
    </tbody>
</table>

{
   
   
   # 遮罩层 #}
<div id="shadows" class="shadow hide"></div>

{
   
   
   # 添加对话框 #}
<div id="addModal" class="modal hide">
    <h3>添加班级</h3>
    <p><input type="text" id="add_title_id" placeholder="添加班级"></p>
    <span id="add_errmsg" style="color:red"></span>
    <p>
        <input type="button" id="btnAdd" value="添加">
        <input type="button" class="hideModal" value="取消">
    </p>
</div>

{
   
   
   # 编辑对话框 #}
<div id="EditModal" class="modal hide">
    <h3>编辑班级</h3>
    <p><input type="text" id="edit_class_id" style="display:none"></p>
    <p><input type="text" id="edit_title"></p>
    <span id="edit_errmsg" style="color:red"></span>
    <p>
        <input type="button" value="更新" id="btnedit">
        <input type="button" value="取消" class="hideModal">
    </p>

</div>
<script src="/static/jquery-3.4.1.min.js"></script>
<script>
    $(function(){
   
   
   
        $('#openAddModal').click(function(){
   
   
   
            $('#shadows,#addModal').removeClass('hide')
        });
        $('.hideModal').click(function(){
   
   
   
            $("#shadows,#addModal,#EditModal").addClass("hide")
        });

        $(".openEditModal").click(function(){
   
   
   
            $('#shadows,#EditModal').removeClass('hide');
            var tds=$(this).parent().prevAll();
            var cid=$(tds[1]).text();
            var title=$(tds[0]).text();
            $("#edit_class_id").val(cid);
            $("#edit_title").val(title);
        });

        $("#btnedit").click(function(){
   
   
   
            $.ajax({
   
   
   
                url:"{% url "classes:class_updata" %}",
                type:"post",
                data:{
   
   
   
                    "cid":$("#edit_class_id").val(),
                    "title":$("#edit_title").val()
                },
                success:function(args){
   
   
   
                   args=JSON.parse(args);
                   if(args.status){
   
   
   
                       location.reload();
                   }else{
   
   
   
                       $("#edit_errmsg").text(args.errmsg);
                   }
               }
            })
        });

        $(".btnDel").click(function(){
   
   
   
            var tds=$(this).parent().prevAll();
            var cid=$(tds[1]).text();
            $.ajax({
   
   
   
                url:"{% url "classes:class_del" %}",
                type:"post",
                data:{
   
   
   
                    "cid":cid
                },
                success:function(args){
   
   
   
                    args=JSON.parse(args);
                    if(args.status){
   
   
   
                        location.reload()
                    }else{
   
   
   
                        alert(args.errmsg)
                    }
                }
            })
        });

        $("#btnAdd").click(function(){
   
   
   
           $.ajax({
   
   
   
               url:"{% url "classes:class_add" %}",
               type:"post",
               data:{
   
   
   
                   "title":$("#add_title_id").val()
               },
               success:function(args){
   
   
   
                   args=JSON.parse(args);
                   if(args.status){
   
   
   
                       location.reload();
                   }else{
   
   
   
                       $("#add_errmsg").text(args.errmsg);
                   }
               }
           })
        });
    })
</script>


</body>
</html>


from django.shortcuts import render, HttpResponse, redirect
from django.views.generic import View
from apps.utils.sqlhelp import SqlHelper
import json
# Create your views here.
class ClassesView(View):
    def get(self,request):
        obj=SqlHelper()
        sql="select * from class"
        result=obj.get_list(sql,())
        obj.close()
        return render(request, "class.html", {
   
   
   "result":result})

class Class_addf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            title=request.POST.get("title")
            if title:
                obj=SqlHelper()
                sql="insert into class(title) values(%s)"
                obj.modify(sql,title)
                obj.close()
            else:
                ret["status"] = False
                ret["errmsg"] = "班级名称不能为空"
        except:
            ret["status"]=False
            ret["errmsg"]="添加失败"
        return HttpResponse(json.dumps(ret))

class Class_delf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            cid=request.POST.get("cid")
            obj=SqlHelper()
            obj.modify("delete from class where id=%s",cid)
            obj.close()
        except:
            ret["status"]=False
            ret["errmsg"]="删除失败"
        return HttpResponse(json.dumps(ret))

class Class_updataf(View):
    def post(self,request):
        ret = {
   
   
   "status": True, "errmsg": None}
        try:
            cid=request.POST.get("cid")
            title = request.POST.get("title")
            if cid and title:
                obj = SqlHelper()
                obj.modify("update class set title=%s where id=%s", (title,cid))
                obj.close()
                print(cid,title)
            else:
                ret["status"] = False
                ret["errmsg"] = "班级不能为空"
        except:
            ret["status"] = False
            ret["errmsg"] = "更新失败"
        return HttpResponse(json.dumps(ret))

2、学生表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用Jquery、Ajax实现。

Django (二)使用 JQuery、Ajax

Django (二)使用 JQuery、Ajax
Django (二)使用 JQuery、Ajax

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生列表</title>
    <link rel="stylesheet" href="/static/common.css">
</head>
<body>
<h3>学生列表</h3>
<div><a id="openAddModal">添加</a></div>
<table border="1"cellspacing="0">
    <thead>
        <td>学生ID</td>
        <td>学生姓名</td>
        <td>班级名称</td>
        <td>操作</td>
    </thead>
        <tbody>
            <tr>
                {
   
   
   % for item in result%}
                <td >{
   
   
   {
   
   
    item.id }}</td>
                <td>{
   
   
   {
   
   
    item.name }}</td>
                <td class_id="{
   
   
   { item.class_id}}">{
   
   
   {
   
   
    item.title }}</td>
                <td>
                    <a class="openEditModal">编辑</a>
                    |
                    <a class="btnDel">删除</a>
                </td>
            </tr>
            {
   
   
   % endfor %}
        </tbody>
</table>
{
   
   
   # 遮罩层 #}
<div id="shadow" class="hide shadow"></div>

{
   
   
   # 添加模态框 #}
<div id="addModal" class="hide modal">
    <h3>添加学生</h3>
    <p><input type="text" id="student_name" placeholder="学生姓名"></p>
    <span id="errmsg" style="color:red"></span>
    <p><select id="class_id" size="7">
        {
   
   
   % for item in class_list %}
            <option value="{
   
   
   { item.id }}">{
   
   
   {
   
   
    item.title }}</option>
        {
   
   
   % endfor %}
    </select></p>
    <p><input type="button" id="btnAdd" value="添加">
    <input type="button" class="hideModal" value="取消"></p>
</div>

{
   
   
   # 编辑模态框 #}
<div id="editModal" class="hide modal">
    <p><input type="text" style="display:none" id="edit_student_id"></p>
    <p><input type="text" id="edit_student_name"></p>
    <p>
        <select id="edit_class_id"  size="7">
            {
   
   
   % for item in class_list %}
                <option value="{
   
   
   { item.id }}">{
   
   
   {
   
   
    item.title}}</option>
            {
   
   
   % endfor %}
        </select>
    </p>
    <span id="Edit_errmsg" style="color:red"></span>
    <p>
        <input type="button" id="btnEdit" value="编辑">
        <input type="button" class="hideModal" value="取消">
    </p>
</div>

<script src="/static/jquery-3.4.1.min.js"></script>
<script>
    $("#openAddModal").click(function(){
   
   
   
        $("#shadow,#addModal").removeClass("hide")
    });
    $(".openEditModal").click(function(){
   
   
   
        $("#shadow,#editModal").removeClass("hide");

        var std=$(this).parent().prevAll();
        var student_id=$(std[2]).text();
        var student_name=$(std[1]).text();
        var class_id=$(std[0]).attr("class_id");



        $("#edit_student_id").val(student_id);
        $("#edit_student_name").val(student_name);
        $("#edit_class_id").val(class_id)

    });

    $("#btnEdit").click(function(){
   
   
   
        var student_id=$("#edit_student_id").val();
        var student_name=$("#edit_student_name").val();
        var class_id=$("#edit_class_id").val();
        console.log(student_id,student_name,class_id);
        $.ajax({
   
   
   
            url:"{% url "students:student_updata" %}",
            type:"post",
            data:{
   
   
   
                "student_id":student_id,
                "student_name":student_name,
                "class_id":class_id
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status){
   
   
   
                    location.reload();
                }else{
   
   
   
                    $("#Edit_errmsg").val(args.errmsg);
                    //alert(args.errmsg);
                }
            }

        });
    });

    $(".hideModal").click(function(){
   
   
   
        $("#shadow,#addModal,#editModal").addClass("hide")
    });
    $("#btnAdd").click(function(){
   
   
   
        var student_name=$("#student_name").val();
        var class_id=$("#class_id").val();
        $.ajax({
   
   
   
            url:"{% url "students:student_add" %}",
            type:"post",
            data:{
   
   
   
                "student_name":student_name,
                "student_class":class_id
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status) {
   
   
   
                    location.reload();
                } else{
   
   
   
                    $("#errmsg").text(args.errmsg);
                }
            }})
    });
    $(".btnDel").click(function(){
   
   
   
        var std=$(this).parent().prevAll()
        var cid=$(std[2]).text()
        $.ajax({
   
   
   
            url:"{% url "students:student_del" %}",
            type:"post",
            data:{
   
   
   
                "student_id":cid
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status){
   
   
   
                    location.reload();
                }else{
   
   
   
                    alert(args.errmsg)
                }
            }
        })
    });

</script>
</body>
</html>


from django.shortcuts import render, HttpResponse, redirect
from django.views.generic import View
from apps.utils.sqlhelp import SqlHelper
import json

class Students(View):
    def get(self,request):
        obj=SqlHelper()
        sql="select student.id,name,title ,student.class_id from class,student where class_id=class.id"
        result=obj.get_list(sql,())
        sql = "select * from class"
        sql = "select * from class"
        class_list = obj.get_list(sql, ())
        obj.close()
        return render(request, "student_class.html", {
   
   
   "result": result,"class_list":class_list})

class Student_addf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            student_name=request.POST.get("student_name")
            cid=request.POST.get("student_class")
            if student_name and cid:
                obj = SqlHelper()
                sql1 = "insert into student(name,class_id) values(%s,%s)"
                obj.modify(sql1,(student_name,cid))
                obj.close()
            else:
                ret["status"] = False
                ret["errmsg"] = "名字和班级不能为空"
        except:
            ret["status"]=False
            ret["errmsg"]="添加失败"
        return HttpResponse(json.dumps(ret))

class Student_delf(View):
    def post(self,request):
        print("7"*40)
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            student_id=request.POST.get("student_id")
            print(student_id)
            obj=SqlHelper()
            obj.modify("delete from student where id=%s",student_id)
            obj.close()
        except:
            ret["status"]=False
            ret["errmsg"]="删除失败"
        return HttpResponse(json.dumps(ret))

class Student_updataf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            student_id = request.POST.get("student_id")
            student_name = request.POST.get("student_name")
            cid=request.POST.get("class_id")
            print("*"*50)
            print(student_id,student_name,cid)
            if student_id and student_name and cid:
                obj = SqlHelper()
                obj.modify("update student set name=%s,class_id=%s where id=%s", (student_name,cid,student_id))
                obj.close()
            else:
                ret["status"] = False
                ret["errmsg"] = "填写内容不能为空"
        except:
            ret["status"]=False
            ret["errmsg"]="编辑失败"
        return HttpResponse(json.dumps(ret))

3、教师表的操作,包括增加、编辑、删除。要求(1)增加、编辑,弹出对话框;(2)这些操作用Jquery、Ajax实现。

Django (二)使用 JQuery、Ajax

Django (二)使用 JQuery、Ajax
Django (二)使用 JQuery、Ajax

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教师列表</title>
    <link rel="stylesheet" href="/static/common.css">
</head>
<body>
<h3>教师列表</h3>
<div><a id="openAddTeacher">添加</a></div>
<table border="1" cellspacing="0">
    <thead>
    <tr>
        <td>ID</td>
        <td>教师姓名</td>
        <td>任教班级</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    {
   
   
   % for item in result %}
        <tr>
        <td>{
   
   
   {
   
   
    item.id }}</td>
        <td>{
   
   
   {
   
   
    item.name }}</td>
        <td>
            {
   
   
   % for title in item.titles %}
                <span style="display:inline-block;padding:5px;border:1px solid red">{
   
   
   {
   
   
    title }}</span>
            {
   
   
   % endfor %}
        </td>
        <td>
            <a class="openEditModal">编辑</a>
            <a class="btnDel">删除</a>
        </td>
        </tr>
    {
   
   
   % endfor %}
    </tbody>
</table>

<div id="shadow" class="shadow hide"></div>

<div id="AddModal" class="modal hide">
    <h3>增加老师</h3>
    <p><input type="text" placeholder="教师姓名" id="add_teacher_name"></p>
    <p><select id="add_cids" multiple size="7">
        {
   
   
   % for item in class_list %}
            <option value="{
   
   
   { item.id }}">{
   
   
   {
   
   
    item.title }}</option>
        {
   
   
   % endfor %}
    </select></p>
    <span id="add_errmsg"></span>
    <p><input type="button" value="添加" id="btnAdd">
        <input type="button" value="取消" class="hideModal">
    </p>
</div>

<div id="EditModal" class="modal hide">
    <h3>编辑教师</h3>
    <p><input style="display:none" type="text" id="edit_teacher_id" value="{
   
   
   { teacher_id}}"></p>
    <p><input type="text" id="edit_teacher_name" value="{
   
   
   { teacher_name }}"></p>
    <p><select id="edit_teacher_classes" multiple size="7">
        {
   
   
   % for item in class_list %}
            <option value="{
   
   
   { item.id }}">{
   
   
   {
   
   
    item.title }}</option>
        {
   
   
   % endfor %}
    </select></p>
    <span id="edit_errmsg"></span>
    <p><input type="button" value="更新" id="btnEdit">
    <input type="button" value="取消" class="hideModal"></p>
</div>

<script src="/static/jquery-3.4.1.min.js"></script>
<script>

    $("#openAddTeacher").click(function(){
   
   
   
        $("#AddModal,#shadow").removeClass("hide")
    });
    $(".openEditModal").click(function(){
   
   
   
        $("#EditModal,#shadow").removeClass("hide");

        var std=$(this).parent().prevAll();
        var teacher_id=$(std[2]).text();
        var teacher_name=$(std[1]).text();
        var teacher_classes=$(std[0]).text();

        $("#edit_teacher_id").val(teacher_id);
        $("#edit_teacher_name").val(teacher_name);

        $("#edit_teacher_classes option").each(function(){
   
   
   
            console.log(txt);
            var txt=$(this).text();
            if(teacher_classes.indexOf(txt)!=-1){
   
   
   
                $(this).attr("selected",true);
            } else{
   
   
   
                $(this).attr("selected",false);
            }
        });

    });
    $(".hideModal").click(function(){
   
   
   
        $("#AddModal,#shadow,#EditModal").addClass("hide")
    });

    $("#btnEdit").click(function(){
   
   
   
        var teacher_id=$("#edit_teacher_id").val();
        var teacher_name=$("#edit_teacher_name").val();
        var teacher_classes=$("#edit_teacher_classes").val();
        console.log(teacher_id,teacher_name,teacher_classes)
        $.ajax({
   
   
   
            url:"{% url "teachers:teacher_updata" %}",
            type:"post",
            traditional:true,
            data:{
   
   
   
                "teacher_id":teacher_id,
                "teacher_name":teacher_name,
                "teacher_classes":teacher_classes
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status){
   
   
   
                    location.reload();
                }else{
   
   
   
                    $("#edit_errmsg").text(args.errmsg);
                }

            }
        })
    });

    $("#btnAdd").click(function(){
   
   
   
        var teacher_name=$("#add_teacher_name").val();
        var class_ids=$("#add_cids").val();
        console.log(teacher_name,class_ids);

        $.ajax({
   
   
   
            url:"{% url "teachers:teacher_add" %}",
            type:"post",
            traditional:true,
            data:{
   
   
   
                "teacher_name":teacher_name,
                "class_ids":class_ids
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status){
   
   
   
                    location.reload();
                }else{
   
   
   
                    $("#add_errmsg").text(args.errmsg)
                }
            }
        });
    });

    $(".btnDel").click(function(){
   
   
   
        var std=$(this).parent().prevAll();
        var teacher_id=$(std[2]).text();
        console.log("*********");
        console.log(teacher_id);
        $.ajax({
   
   
   
            url:"{% url "teachers:teacher_del" %}",
            type:"post",
            data:{
   
   
   
                "teacher_id":teacher_id
            },
            success:function(args){
   
   
   
                args=JSON.parse(args);
                if(args.status){
   
   
   
                    location.reload();
                }else{
   
   
   
                    alert(args.errmsg);
                }
            }
        })
    });


</script>

</body>
</html>


from django.shortcuts import render,HttpResponse,redirect
from apps.utils.sqlhelp import SqlHelper
from django.views.generic import View
import json
# Create your views here.

class Teachers(View):
    def get(self,request):
        obj=SqlHelper()
        sql="""
        select teacher.id,teacher.name,class.title from teacher
        left JOIN teacher2class on teacher.id=teacher2class.teacher_id
        left JOIN class on teacher2class.class_id=class.id
        """
        result=obj.get_list(sql,())
        dic={
   
   
   }
        for item in result:
            if item["id"] in dic:
                dic[item["id"]]["titles"].append(item["title"])
            else:
                dic[item["id"]]={
   
   
   "id":item["id"],"name":item["name"],"titles":[item["title"]]}
        result=dic.values()

        class_list=obj.get_list("select * from class",())
        obj.close()
        return render(request,"teachers.html",{
   
   
   "result":result,"class_list":class_list})

class Teacher_addf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            teacher_name=request.POST.get("teacher_name")
            teacher_class=request.POST.getlist("class_ids")
            print(teacher_name,teacher_class)

            if teacher_name and teacher_class:
                obj=SqlHelper()
                sql="insert into teacher(name) values(%s)"
                tid=obj.create(sql,teacher_name)
                sql="insert into teacher2class(teacher_id,class_id) values(%s,%s)"
                lst=[(tid,item) for item in teacher_class]
                obj.modify_many(sql,lst)
            else:
                ret["status"] = False
                ret["errmsg"] = "填写内容不能为空"
        except:
            ret["status"]=False
            ret["errmsg"]="教师添加失败"
        return HttpResponse(json.dumps(ret))


class Teacher_delf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            tid=request.POST.get("teacher_id")
            obj=SqlHelper()
            sql="delete from teacher where teacher.id=%s"
            obj.modify(sql,tid)
            sql="delete from teacher2class where teacher_id=%s"
            obj.modify(sql, tid)
        except:
            ret["status"]=False
            ret["errmsg"]="删除失败"
        return HttpResponse(json.dumps(ret))

class Teacher_updataf(View):
    def post(self,request):
        ret={
   
   
   "status":True,"errmsg":None}
        try:
            teacher_id=request.POST.get("teacher_id")
            teacher_name = request.POST.get("teacher_name")
            teacher_classes=request.POST.getlist("teacher_classes")
            print(teacher_id,teacher_name,teacher_classes)
            if teacher_id and teacher_name and teacher_classes:
                obj=SqlHelper()
                sql="update teacher set name=%s where id=%s"
                obj.modify(sql,(teacher_name,teacher_id))

                sql="delete from teacher2class where teacher_id=%s"
                obj.modify(sql,teacher_id)

                sql = "insert into teacher2class(teacher_id,class_id) values(%s,%s)"
                lst = [(teacher_id, item) for item in teacher_classes]
                obj.modify_many(sql, lst)
            else:
                ret["status"] = False
                ret["errmsg"] = "填写内容不能为空"
        except:
            ret["status"]=False
            ret["errmsg"]="编辑失败"
        return HttpResponse(json.dumps(ret))

本文同步分享在 博客“战 胜”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
java将前端的json数组字符串转换为列表
记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Easter79 Easter79
3年前
sql注入
反引号是个比较特别的字符,下面记录下怎么利用0x00SQL注入反引号可利用在分隔符及注释作用,不过使用范围只于表名、数据库名、字段名、起别名这些场景,下面具体说下1)表名payload:select\from\users\whereuser\_id1limit0,1;!(https://o
Stella981 Stella981
3年前
Nginx + lua +[memcached,redis]
精品案例1、Nginxluamemcached,redis实现网站灰度发布2、分库分表/基于Leaf组件实现的全球唯一ID(非UUID)3、Redis独立数据监控,实现订单超时操作/MQ死信操作SelectPollEpollReactor模型4、分布式任务调试Quartz应用
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这