Skip to content

Instantly share code, notes, and snippets.

@alexander-ae
Forked from ndarville/settings.py
Created December 13, 2015 02:14
Show Gist options
  • Save alexander-ae/1f315380ab43a0600b3d to your computer and use it in GitHub Desktop.
Save alexander-ae/1f315380ab43a0600b3d to your computer and use it in GitHub Desktop.
Django on Travis CI
"""A basic database set-up for Travis CI.
The set-up uses the 'TRAVIS' (== True) environment variable on Travis
to detect the session, and changes the default database accordingly.
Be mindful of where you place this code, as you may accidentally
assign the default database to another configuration later in your code.
"""
import os
# (...)
if 'TRAVIS' in os.environ:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'travisci',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '',
}
}
# (...)
# A basic travis.yml boilerplate for Django projects
#
# The set-up assumes a postgreSQL database.
#
# Replace the following variables in the code:
# * your_project_settings
# * your_github_username
# * your_repo
language: python
python:
- 2.6
- 2.7
services: postgresql
env:
- DJANGO=1.4.1
before_install:
- export DJANGO_SETTINGS_MODULE=your_project.settings
- export PYTHONPATH=$HOME/builds/your_github_username/your_repo
- export PIP_USE_MIRRORS=true
install:
- pip install -r requirements.txt
- pip install django==$DJANGO --quiet
- pip install psycopg2 --quiet
before_script:
- psql -c "CREATE DATABASE mydb;" -U postgres
script:
- python manage.py syncdb --noinput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment