摘要: python写一个入库脚本 通过excel上传用例 入库 user-views下增加init_db方法: def init_db(request): #1、excel读取数据 #读作者信息 就会同步两张表 引入xlrd #读取第一个sheet页 workbook = xlrd.open_workbo 阅读全文
posted @ 2020-06-06 09:57 钱小多多多 阅读(176) 评论(0) 推荐(0)
摘要: #元组:不可变的类型,操作数据库的时候一般用二维元组,数据类型可以放任意类型 字符串也不可以通过索引修改值#一个值的元组 a = 1, 可以索引 分片#删除 del 整个元组删除a = (1,2,3,4,4)# del(a)# print(a)#y元组可以做加法 乘法b = (3,4,5)print 阅读全文
posted @ 2020-06-06 07:27 钱小多多多 阅读(179) 评论(0) 推荐(0)
摘要: 看见看见了 阅读全文
posted @ 2020-06-06 06:34 钱小多多多 阅读(370) 评论(0) 推荐(0)
摘要: 在应用层有个model.py文件,数据库的操作都写在这个文件中 首先需要引入models from django.db import models class User(models.Model):#肯定不是特殊的类 username = models.CharField(null=False,ma 阅读全文
posted @ 2020-06-03 15:19 钱小多多多 阅读(248) 评论(1) 推荐(0)
摘要: @api_view(["POST"])#有页面返回了所以去掉getdef api_login(request): username = request.POST.get("username") pwd = request.POST.get("password") is_login = request 阅读全文
posted @ 2020-06-01 22:29 钱小多多多 阅读(201) 评论(0) 推荐(0)
摘要: 基于代码: def login(request): return render(request,"home.html") #给用户一个静态页 @api_view(["POST"])#有页面返回了所以去掉getdef api_login(request): username = request.POS 阅读全文
posted @ 2020-05-29 12:52 钱小多多多 阅读(176) 评论(0) 推荐(0)
摘要: 文件路径user/login 一、登录接口;get请求 username password url参数传递 二、登录接口:post请求,username password url-encode表单传递 意思实现的功能是 : ①、实现一:用户名和密码都是admin 显示 home.html 提示欢迎登 阅读全文
posted @ 2020-05-29 07:36 钱小多多多 阅读(1701) 评论(0) 推荐(0)
摘要: 1、每个应用都要创建一个ulrs.py文件,即二级路由 # render(request, template_name, context=None, content_type=None, status=None, using=None):render方法返回需要传的参数 阅读全文
posted @ 2020-05-28 22:04 钱小多多多 阅读(212) 评论(0) 推荐(0)
摘要: 引入相关包 from django.http import HttpResponse了解HttpResponse类的初始化函数content_type:响应正文 指定响应的数据格式--客户端需要知道主体是什么类型的资源(默认为:'text/html') status:响应的HTTP响应状态码reas 阅读全文
posted @ 2020-05-19 23:20 钱小多多多 阅读(199) 评论(0) 推荐(0)
摘要: 该文章主要是介绍如何开发一个请求接口 请求接口的请求方式取决与前端传的类型,所以在定义api文档的时候,需要和前端沟通好,前端用什么格式给后端,后端接口接到请求后用什么类型格式返回给前端 1、如何处理一个请求,用户的请求不需要创建,只需要你使用 2、用户的响应需要你创建 requests如何用呢? 阅读全文
posted @ 2020-05-19 18:29 钱小多多多 阅读(476) 评论(0) 推荐(0)