0

I am following this to deploy a Django project to Heroku and try to create two git remotes. Due to the lack of a django template during the step: File | New | Project | Heroku | Create Heroku App from Template, I selected the Blank Heroku App template.

An then, I set the project to be both PyDev and Django (PyDev | Set as PyDev Project, PyDev | Set as Django Project), followed by copying the following required files from another standard Django project with appropriate changes to the file contains:

manage.py
Profile
requirements.txt
runtime.txt
/<projectName>
    __init__.py
    settings.py
    urls.py
    wsgi.py

The final step was to make database migration (Postgres).

Everything went fine locally. However, after I deployed the project successfully to Heroku, I got a "Application Error" message.

What could be the problem?

In addition, could it be that I chose Blank Heroku App and Heroku has no idea that this is a Django project?

3
  • Traceback from heroku logs would be better to investigate ...! Commented Jan 11, 2015 at 4:09
  • Yes, there was something wrong: django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. I followed the Heroku's steps to set DATABASES = {'default':dj_database_url.config()} and SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https'). What have I missed? Commented Jan 11, 2015 at 4:17
  • Problem solved: you need to provision a postgres database manually ($heroku addons:add heroku-postgresql). Commented Jan 11, 2015 at 4:33

1 Answer 1

1

Your database must be created on Heroku. Run this command in Git (or your Heroku client)-

$heroku addons:add heroku-postgresql

This creates an empty PostGRES database on Heroku.

Next, your settings on the deployed site must reflect the database. The dj_database_url that is part of the heroku_toolbelt python module will automatically query Heroku to get the live database settings. Make these changes to your Django site (the cling module is also part of the Heroku Toolbelt).

settings.py

import dj_database_url
DATABASES['default'] =  dj_database_url.config()

wsgi.py

from django.core.wsgi import get_wsgi_application
from dj_static import Cling

application = Cling(get_wsgi_application())

Finally, you must actually sync the Django models to the database (with a database provisioned on Heroku and your Django project settings pointing to the database). This is also done through Git-

heroku run python manage.py syncdb

In fact, any Django terminal commands can be run in this matter (for example, running a South migration on your Heroku DB can done with run python manage.py migrate app_name).

For more info, read here - https://devcenter.heroku.com/articles/getting-started-with-django

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.