摘要: Linux 系统中很多 shell,包括bash,sh,zsh,dash 和 korn 等,不管哪种 shell 都会有一个 的隐藏文件,它就相当于 shell 的配置文件。 一般会有多个 文件,使用 命令可以查看: 不同目录下的 文件其作用不尽相同,比如: :文件将复制到系统上创建的任何新用户的主 阅读全文
posted @ 2019-06-11 23:31 Hubery_Jun 阅读(70617) 评论(0) 推荐(4) 编辑
摘要: 1. logging 1.1 什么是 logging logging 模块是 Python 内置的日志管理模块,不需要额外安装。 使用: import logging logging.critical('this is critical msg') logging.error('this is er 阅读全文
posted @ 2019-06-11 12:00 Hubery_Jun 阅读(666) 评论(0) 推荐(0) 编辑
摘要: 通过依赖文件,别人在使用我们的项目时,不需要再一个个去安装所需模块,只需安装依赖文件即可。 1. 导出整个虚拟环境依赖 # 在项目根目录中,打开终端执行以下命令 # 生成 requirements.txt 文件 pip3 freeze > requirements.txt # 安装依赖文件 pip3 阅读全文
posted @ 2019-06-11 11:59 Hubery_Jun 阅读(2776) 评论(0) 推荐(0) 编辑
摘要: 众所周知前端向后台发送 post 请求时,必须验证 csrf,否则会报错 403 Forbidden。使用 Django Form 表单可以直接在表单里面添加 {% csrf_token %} 即可,要是通过 Ajax 发送请求又该怎么办?下面提供三种解决办法: <ul id="ddd"> <li> 阅读全文
posted @ 2019-06-10 11:43 Hubery_Jun 阅读(37422) 评论(0) 推荐(0) 编辑
摘要: Django 内置一个 auth 模块,帮助用户实现注册、登录、注销以及修改密码等功能,帮助开发者省去了很多功夫。 auth 模块 在创建模型时,Django内部会生成一个名为 auth_user 的数据表,用于存储认证的用户信息。 auth 模块提供了一系列的方法,使用之前需要导入: from d 阅读全文
posted @ 2019-06-08 22:48 Hubery_Jun 阅读(663) 评论(0) 推荐(0) 编辑
摘要: 1. django-simple-captcha 模块 安装 django-simple-captcha pip install django-simple-captcha pip install Pillow 注册 和注册 app 一样,captcha 也需要注册到 settings 中。同时它也 阅读全文
posted @ 2019-06-08 22:46 Hubery_Jun 阅读(9123) 评论(2) 推荐(0) 编辑
摘要: 1. uWSGI 服务器 Django 默认使用 WSGI(Python Web Server Gateway ) 作为 Web 服务器,一般仅用来作为测试使用,实际生产环境而是使用 uWSGI 和 Nginx 作为服务器。 uWSGI 代码完全用C编写,效率高、性能稳定,但是处理 静态文件能力较弱 阅读全文
posted @ 2019-06-08 22:40 Hubery_Jun 阅读(2318) 评论(0) 推荐(1) 编辑
摘要: def check_login(func): # 自定义登录验证装饰器 def warpper(request, *args, **kwargs): is_login = request.session.get('is_login', False) if is_login: func(request 阅读全文
posted @ 2019-06-08 22:39 Hubery_Jun 阅读(2114) 评论(0) 推荐(0) 编辑
摘要: JsonResponse 是 HttpResponse 的子类,与父类的区别在于: JsonResponse 默认 Content-Type 类型为 application/json HttpResponse 默认为 application/text class JsonResponse(HttpR 阅读全文
posted @ 2019-06-08 22:37 Hubery_Jun 阅读(2476) 评论(0) 推荐(0) 编辑
摘要: 1. logging 1.1 什么是 logging logging 模块是 Python 内置的日志管理模块,不需要额外安装。 使用: import logging logging.critical('this is critical msg') logging.error('this is er 阅读全文
posted @ 2019-06-08 22:34 Hubery_Jun 阅读(484) 评论(0) 推荐(0) 编辑