处理环境配置位置问题
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import os
|
||||
|
||||
from .settings import Settings
|
||||
from .settings import BASE_DIR, Settings
|
||||
|
||||
_env = os.getenv("ENV", "dev")
|
||||
_env_files = {"dev": ".env", "test": ".env.test", "pro": ".env.prod"}
|
||||
|
||||
settings = Settings(_env_file=_env_files.get(_env, ".env"))
|
||||
# 使用基于项目根目录的绝对路径,避免受 PyCharm/命令行工作目录(CWD)影响
|
||||
_env_file = BASE_DIR / _env_files.get(_env, ".env")
|
||||
|
||||
settings = Settings(_env_file=_env_file)
|
||||
|
||||
__all__ = ["settings"]
|
||||
|
||||
Reference in New Issue
Block a user