本文整理汇总了Python中environ.Env.db_url方法的典型用法代码示例。如果您正苦于以下问题:Python Env.db_url方法的具体用法?Python Env.db_url怎么用?Python Env.db_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environ.Env
的用法示例。
在下文中一共展示了Env.db_url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url [as 别名]
from environ import Env
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
assert os.path.isfile(os.path.join(BASE_DIR, 'manage.py'))
env = Env()
env.read_env(os.path.join(BASE_DIR, '.env'))
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('' if not DEBUG else 'xxx'))
DATABASES = {
'default': env.db_url(
default='psql://tallessa:[email protected]/tallessa',
),
}
CACHES = {'default': env.cache_url(default='locmemcache://')}
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
示例2: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url [as 别名]
import os
from environ import Env
env = Env()
HOME_DIR = env.str(
"HOME_DIR",
default=os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
)
env.read_env(os.path.join(HOME_DIR, ".env"))
DEBUG = env.bool("DEBUG", False)
SECRET_KEY = env.bool("SECRET_KEY", "Sehr lecker Wurst" if DEBUG else Env.NOTSET)
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
DATABASES = {
"default": env.db_url(default="sqlite:///%s" % os.path.join(HOME_DIR, "wurst.sqlite3"))
}
STATIC_ROOT = env.str("STATIC_ROOT", default=os.path.join(HOME_DIR, "static"))
MEDIA_ROOT = env.str("MEDIA_ROOT", default=os.path.join(HOME_DIR, "media"))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'reversion',
'rest_framework',
'rest_framework.authtoken',
'wurst.core',
示例3: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url [as 别名]
import os
import babel
from environ import Env
env = Env()
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('cfh' if DEBUG else Env.NOTSET))
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': env.db_url(default='postgis://postgres:[email protected]:5432/cfh')
}
INSTALLED_APPS = list(filter(None, [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'rest_framework',
'parler',
'cfh',
'issues',
'issues_citysdk',
'issues_media',
'issues_hel',
'issues_log',
示例4: exec
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url [as 别名]
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
DATABASES = {
"default": env.db_url(default="sqlite:///%s" % os.path.join(BASE_DIR, "db.sqlite3")),
}
# local_settings.py can be used to override environment-specific settings
# like database and email that differ between development and production.
f = os.path.join(BASE_DIR, "local_settings.py")
if os.path.exists(f):
import sys
import imp
module_name = "%s.local_settings" % ROOT_URLCONF.split('.')[0]
module = imp.new_module(module_name)
module.__file__ = f
sys.modules[module_name] = module
exec(open(f, "rb").read())