Tips

作者: 十二右 | 来源:发表于2018-08-21 20:26 被阅读0次

1. all(list) - 只要有一个参数为空,结果即为False

2. 对密码(password)加密和校对

3. 页面传参

4. 封装功能函数到utils包里

5. Ajax 异步请求

6. 强制刷新页面,更新js或css等文件 :

7. 点击页面就调用目标函数,返回数据


1. all(list) - 只要有一个参数为空,结果即为False

例如 :

        if not all([username, password, email, icon]):
            error = {'msg': '参数不能为空'}
            return render(request, 'user/user_register.html', error)

2. 对密码(password)加密和校对

导入模块
from django.contrib.auth.hashers import make_password, check_password
加密
make_password(password)
校对 password - 登录时输入密码; user.password - 被加密过的密码
check_password(password, user.password)

3. 页面传参

image.png

4. 封装功能函数到utils包里

image.png

5. Ajax 异步请求 :

image.png

6. 强制刷新页面,更新js或css等文件 :

第一种 : Ctrl + F5
第二种 : 浏览器设置里清除缓存等数据

7. 点击页面就调用目标函数,返回数据

进入购物页面就及时刷新选购的商品数量


image.png

相关文章

网友评论

      本文标题:Tips

      本文链接:https://www.haomeiwen.com/subject/ybqzbftx.html