@csrf_exempt: 取消csrftoken验证。https://www.jianshu.com/p/a178f08d9389
python@装饰器:它们封装一个函数,并且用这样或者那样的方式来修改它的行为。http://www.runoob.com/w3cnote/python-func-decorators.html
Django对齐HTML代码快捷键:Ctrl+Alt+L
sha1加密,安全哈希算法。https://www.jianshu.com/p/a6b54d6981a5 单项加密,不可解密
AES加密,高级加密标准。https://stackoverflow.com/questions/15956952/how-do-i-decrypt-using-hashlib-in-python 加密解密
from Crypto.Cipher import AES
import base64
secret_key = "QWqw12!@QWqw12!@" #密钥
cipher = AES.new(secret_key,AES.MODE_ECB) # never use ECB in strong systems obviously
msg_text = "******" #要加密的密码
if len(msg_text) < 16: #假设密码长度为6-16之间
msg_text += " "*(16-len(msg_text)) #长度不够的用空格补齐
print("msg_text:",msg_text)
encoded = base64.b64encode(cipher.encrypt(msg_text))
# ...
print("encoded:", encoded)
decoded = cipher.decrypt(base64.b64decode(encoded))
decoded = bytes.decode(decoded) # bytes to str
print("decoded:", decoded.strip(" ")) #将空格去掉
注:加密完是bytes格式的,如果加入数据库先将bytes转换成str,数据库中存储字符串str,从数据库读出解密就先将str转换成bytes再解密
python中str与bytes互转:https://www.cnblogs.com/timelesszhuang/p/7235798.html
在线加密解密网站:http://tool.oschina.net/encrypt
jQuery cookie包下载地址:http://plugins.jquery.com/cookie/
实现“记住我”功能:https://blog.csdn.net/Fmuma/article/details/78445824 除此之外,记得引用jQuery包与jQuery cookie包,并且jQuery包一定要在jQuery cookie包前引用,否则会报错$.cookie is not a function(详见:https://blog.csdn.net/qq_31935559/article/details/79791276)
顺序如下:
<script src="/static/js/jquery-1.10.2.min.js"></script>
<script src="/static/js/jquery-1.11.1.min.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/jquery.cookie.js"></script>
Django获取Cookie:https://www.cnblogs.com/skying555/p/4964112.html
user_email = request.COOKIES["qwer"]
Django表单提交并报错:CSRF token missing or incorrect,解决:在<form>底下加{% csrf_token %},详细:https://blog.csdn.net/u012561176/article/details/82178839
Django ORM更新数据:https://mp.weixin.qq.com/s/B_aNB8Y8snbSVLURONZ4Qg
table_name.objects.filter(id=1).update(username='nick',password="123")
Django ORM 查询数据:https://www.cnblogs.com/qiangayz/p/8972673.html
result = models.table_name.objects.filter(username='root',password='root123')
for row in result:
print row.id,row.username,row.password
HTML中,disabled的input不能post传输!
Ajax(Asynchronous Javascript And XML),异步js和xml,是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术。通过在后台与服务器进行少量数据交换,Ajax可以使网页实现异步更新。这意味着可以在不重新加载整个网页的情况下,对网页的某部分进行更新。(来源:百度百科 https://baike.baidu.com/item/ajax/8425?fr=aladdin)
.bootstrapValidator:表单验证,验证格式、空值等:https://www.cnblogs.com/nele/p/5493414.html
bootstrap fileinput插件使用:https://github.com/kartik-v/bootstrap-fileinput/
MySQL创建utf-8字符集数据库:CREATE DATABASE test2 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
推荐一个很漂亮前端框架ACE:http://ace.jeka.by/
Bootstrap表单构造器,拖拽生成表单代码:http://www.bootcss.com/p/bootstrap-form-builder/
明日更......