django继承setting.py文件后设置参数

from 项目名.settings.baseimport *

import os

import sys

# 设置导入应用路径

sys.path.insert(0, os.path.join(os.path.dirname(BASE_DIR), 'apps'))

# print(sys.path)

# 注册应用

INSTALLED_APPS += [

    # 注册的应用路由

]

# 添加数据库

DATABASES = {

'default': {

'ENGINE':'django.db.backends.mysql',

        'USER':'数据库登录用户名',

        'PASSWORD':'root',        

        'HOST':'主机ip',

        'PORT':3306,  

        'NAME':'数据库名',

    }

}

# 注册数据库模型

# AUTH_USER_MODEL = 'user.UsersModel'

# 设置工程日志

LOGGING = {

'version':1,

    'disable_existing_loggers':False,  # 是否禁用已经存在的日志器

    'formatters': {# 日志信息显示的格式

        'verbose': {

'format':'%(levelname)s %(asctime)s %(module)s %(lineno)d %(message)s'

        },

        'simple': {

'format':'%(levelname)s %(module)s %(lineno)d %(message)s'

        },

    },

    'filters': {# 对日志进行过滤

        'require_debug_true': {# django在debug模式下才输出日志

            '()':'django.utils.log.RequireDebugTrue',

        },

    },

    'handlers': {# 日志处理方法

        'console': {# 向终端中输出日志

            'level':'INFO',

            'filters': ['require_debug_true'],

            'class':'logging.StreamHandler',

            'formatter':'simple'

        },

        'file': {# 向文件中输出日志

            'level':'INFO',

            'class':'logging.handlers.RotatingFileHandler',

            'filename': os.path.join(os.path.dirname(BASE_DIR), 'logs/时间+项目名.log'),  # 日志文件的位置

            'maxBytes':300 *1024 *1024,

            'backupCount':10,

            'formatter':'verbose'

        },

    },

    'loggers': {# 日志器

        'django': {# 定义了一个名为django的日志器

            'handlers': ['console', 'file'],  # 可以同时向终端与文件中输出日志

            'propagate':True,  # 是否继续传递日志信息

            'level':'INFO',  # 日志器接收的最低日志级别

        },

    }

}

你可能感兴趣的:(django继承setting.py文件后设置参数)