摘要: Django 内置一个 auth 模块,帮助用户实现注册、登录、注销以及修改密码等功能,帮助开发者省去了很多功夫。 auth 模块 在创建模型时,Django内部会生成一个名为 auth_user 的数据表,用于存储认证的用户信息。 auth 模块提供了一系列的方法,使用之前需要导入: from d 阅读全文
posted @ 2019-06-08 22:48 Hubery_Jun 阅读(686) 评论(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 阅读(9682) 评论(2) 推荐(0)
摘要: 1. uWSGI 服务器 Django 默认使用 WSGI(Python Web Server Gateway ) 作为 Web 服务器,一般仅用来作为测试使用,实际生产环境而是使用 uWSGI 和 Nginx 作为服务器。 uWSGI 代码完全用C编写,效率高、性能稳定,但是处理 静态文件能力较弱 阅读全文
posted @ 2019-06-08 22:40 Hubery_Jun 阅读(2454) 评论(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 阅读(2144) 评论(0) 推荐(0)
摘要: JsonResponse 是 HttpResponse 的子类,与父类的区别在于: JsonResponse 默认 Content-Type 类型为 application/json HttpResponse 默认为 application/text class JsonResponse(HttpR 阅读全文
posted @ 2019-06-08 22:37 Hubery_Jun 阅读(2511) 评论(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 阅读(513) 评论(0) 推荐(0)