I'm trying to setup TravisCI on my Django project.
I'm using Heroku where a classic pattern is to use env var to get postgres database URL:
settings.py
DEBUG = (os.environ['DJ_DEBUG'] == 'True')
import dj_database_url
DATABASES = {'default': dj_database_url.config(conn_max_age=500)}
example of .env file for my local env
DJ_DEBUG=True
DATABASE_URL=postgres://root:[email protected]:5432/captaincook
Now, here is my .travis.yml conf file, that tries to use the locally created db:
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
The project works everywhere, except when deployed on travis, where I got this Django error:
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
Any idea? Thanks.
You have a typo: DABATASE_URL
instead of DATABASE_URL
.
But I suspect that rather than explicitly using export in before_install
, you should use the env
key:
env:
- DJ_DEBUG=False
- DATABASE_URL=postgres://postgres@localhost/travisdb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With