【发布时间】:2017-03-02 14:17:46
【问题描述】:
我正在尝试在我的 Django 项目中设置 TravisCI。
我正在使用 Heroku,其中一个经典模式是使用 env var 获取 postgres 数据库 URL:
settings.py
DEBUG = (os.environ['DJ_DEBUG'] == 'True')
import dj_database_url
DATABASES = {'default': dj_database_url.config(conn_max_age=500)}
本地环境的 .env 文件示例
DJ_DEBUG=True
DATABASE_URL=postgres://root:captainroot@127.0.0.1:5432/captaincook
现在,这是我的 .travis.yml conf 文件,它尝试使用本地创建的数据库:
language: python
python:
- 3.5
addons:
- postgresql: "9.5"
before_install:
- export DJ_DEBUG=False
- export DABATASE_URL=postgres://postgres@localhost/travisdb
install:
- pip install -r requirements.txt
before_script:
- psql -c "CREATE DATABASE travisdb;" -U postgres
- python captaincook/manage.py migrate --noinput
env:
- DJANGO=1.9.10
script: python captaincook/manage.py test --keepdb
该项目在任何地方都可以工作,除了在 travis 上部署时,我得到了这个 Django 错误:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
有什么想法吗?谢谢。
【问题讨论】: