目录

django-environ

https://django-environ.readthedocs.io/en/latest/

从特定路径加载 .env 文件

  1. # Take environment variables from .env file
  2. environ.Env.read_env(BASE_DIR / '.env') # 这个路径是项目的根目录

数据库 URL 参考

Bash
  1. DATABASE_URL=psql://user:un-githubbedpassword@127.0.0.1:8458/database
  2. SQLITE_URL=sqlite:///my-local-sqlite.db
  3. CACHE_URL=memcache://127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213
  4. REDIS_URL=rediscache://127.0.0.1:6379/1?client_class=django_redis.client.DefaultClient&password=ungithubbed-secret