Skip to content

Instantly share code, notes, and snippets.

@axeliodiaz
Last active August 4, 2017 17:58
Show Gist options
  • Save axeliodiaz/e3f101fe31bf5a4a84feb5514afe136f to your computer and use it in GitHub Desktop.
Save axeliodiaz/e3f101fe31bf5a4a84feb5514afe136f to your computer and use it in GitHub Desktop.
Step by step to configure django heroku

Login in heroku:

heroku login

Add Procfile file:

web: gunicorn project.wsgi --log-file -; python manage.py collectstatic --noinput

Add cat runtime.txt:

python-2.7.13

Add to requirements:

dj_database_url==0.4.2
gunicorn==19.7.1
whitenoise==3.3.0

Add to settings.py file:

import dj_database_url
# Heroku
# Update database configuration with $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
DATABASES['default']['TEST'] = {'NAME': DATABASES['default']['NAME']}

# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  ]

Create PostgreSQL config:

heroku addons:create heroku-postgresql:hobby-dev

Set config:

heroku config:set DISABLE_COLLECTSTATIC=1
heroku config:set DEBUG_COLLECTSTATIC=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment