摘要: 配置在环境变量中 pwd = os.environ.get('password', '123js') 配置中心 pwd = request.get().json()['password'] 阅读全文
posted @ 2022-04-26 18:19 recordlife 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 创建应用 python ../../manage.py startapp user 在配置文件中注册应用 INSTALLED_APPS = ['user'] 在models.py中,创建user表 from django.db import models from django.contrib.au 阅读全文
posted @ 2022-04-26 16:58 recordlife 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 创建一个数据库 # 创建数据库,并配置 -create database book default charset=utf8; 查看用户 # 5.7之前版本 select user,host,password from mysql.user; # 5.7往后的版本 select user,host, 阅读全文
posted @ 2022-04-26 16:30 recordlife 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 在utils文件下面新建response文件 from rest_framework.response import Response class APIResponse(Response): def __init__(self, status=100, msg='成功', http_status= 阅读全文
posted @ 2022-04-26 14:36 recordlife 阅读(75) 评论(0) 推荐(0) 编辑
摘要: dev.py文件中配置以下内容 REST_FRAMEWORK = { 'EXCEPTION_HANDLER': 'utils.exception.common_exception_handler' # 再出异常,会执行这个函数 } 在utils文件夹下新建excepiton.py ## 全局异常捕获 阅读全文
posted @ 2022-04-26 13:57 recordlife 阅读(53) 评论(0) 推荐(0) 编辑
摘要: python ../../manage.py startapp user 阅读全文
posted @ 2022-04-26 12:55 recordlife 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 配置文件的配置(filename的路径要改) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s 阅读全文
posted @ 2022-04-26 12:54 recordlife 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 进入创建的虚拟环境,安装django 使用pycharm创建后台项目 调整目录 #### 调整配置文件 -把配置文件移动到setting文件夹下了,改名为dev.py,再新建了一个pro.py -dev.py:开发阶段用的配置 -pro.py:上线阶段用的配置 -manage.py 中指向的配置文件 阅读全文
posted @ 2022-04-26 00:55 recordlife 阅读(35) 评论(0) 推荐(0) 编辑