本文整理匯總了Python中dj_database_url.config方法的典型用法代碼示例。如果您正苦於以下問題:Python dj_database_url.config方法的具體用法?Python dj_database_url.config怎麽用?Python dj_database_url.config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dj_database_url
的用法示例。
在下文中一共展示了dj_database_url.config方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: INSTALLED_APPS
# 需要導入模塊: import dj_database_url [as 別名]
# 或者: from dj_database_url import config [as 別名]
def INSTALLED_APPS(self):
return super().INSTALLED_APPS + (
'django.contrib.sites',
'django.contrib.flatpages',
'django.contrib.humanize',
'django_gravatar',
'parsley',
'connect',
'connect.config',
'connect.accounts',
'connect.moderation',
'connect.discover',
'connect.connection',
)
# MIDDLEWARE
示例2: update_sal_logging_config
# 需要導入模塊: import dj_database_url [as 別名]
# 或者: from dj_database_url import config [as 別名]
def update_sal_logging_config(config):
"""Reset Sal logging to use config
In most cases, call `get_sal_logging` first to get the existing
config, update it, and then call this function.
args:
config (dict): Config to use, following the
logging.config.dictConfig format.
"""
global _SAL_LOGGING_CONFIG
_SAL_LOGGING_CONFIG = config
logging.config.dictConfig(_SAL_LOGGING_CONFIG)
示例3: get_sal_logging_config
# 需要導入模塊: import dj_database_url [as 別名]
# 或者: from dj_database_url import config [as 別名]
def get_sal_logging_config():
"""Return the current logging config for Sal
returns:
dict following the logging.config.dictConfig format.
"""
return _SAL_LOGGING_CONFIG
# Zero out all of Django's logging decisions. It's easier this way.
示例4: setup_django_environment
# 需要導入模塊: import dj_database_url [as 別名]
# 或者: from dj_database_url import config [as 別名]
def setup_django_environment():
from django.conf import settings
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={
"default": dj_database_url.config(env="DATABASE_URL",
default="postgres://test:test@localhost/test",
conn_max_age=20)
},
SECRET_KEY="not very secret in tests",
USE_I18N=True,
USE_L10N=True,
USE_TZ=True,
TIME_ZONE="Asia/Shanghai",
INSTALLED_APPS=(
"pg_partitioning",
"tests",
),
LOGGING={
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {
"format": "[%(asctime)s] %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S"
}
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "standard"
}
},
"loggers": {
"pg_partitioning.shortcuts": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"pg_partitioning.patch.schema": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
},
}
)
django.setup()