1

I have been struggling for this issue for the whole days while no solutions at all. so I post it here.

I am trying to set up a blog website in Heroku via Django 1.8 which uses Python 3.4.3. I follows the instructions from Heroku website here.

I use "foreman start" to run Django project in my Mac and I already installed all dependence.

Part of my setting.py file involving the database initially looks like:

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

Then I got error: ImproperlyConfigured at /settings.DATABASES is improperly configured. Please supply the ENGINE value.

Then I modify the files by adding one line supplying the ENGINE value:

import dj_database_url
DATABASES = {}
DATABASES['default'] = dj_database_url.config()
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

Based on this post answered by Or Arbel, it should work. But I got another error: ImproperlyConfigured at /settings.DATABASES is improperly configured. Please supply the NAME value.

What should I do next? Actually my Django project is very simple and does not involve any database operations(may need in the future). I just want to make it works on Heroku. Thanks!

Do I need to create a database to continue? I just want to make the webpage works.

Community
  • 1
  • 1
Yuanfei Bi
  • 51
  • 7

2 Answers2

1

Thanks for your guys help, specially souldeux.

Update:

I have fixed the issue by using souldeux's method by providing more informations about the database. Here I want to emphasis that it seems the code from the original Heroku tutorial does not work for Django 1.8:

import dj_database_url   ####not working for my case
DATABASES = {}
DATABASES['default'] = dj_database_url.config()

Initially I did not create a database because I think it is not necessary for simple projects, based on my understanding obtained from Heroku tutorial. Actually it does need to create a database in Heroku to make it works. The tutorial is here. You need run "heroku config -s | grep HEROKU_POSTGRESQL" to get the database information. The format is like:

scheme://username:password@host:port/database

So you can get 'database', 'username', 'password', etc.

Afterwards, modify the 'settings.py' according to souldeux, then run following codes:

git add .
git commit -m "Ready to go to Heroku"
git push heroku master
heroku run python manage.py syncdb

Now it works. But other issues arise like my webpages do not show images... Anyway it solved. Please confirm my solutions, thanks.

Yuanfei Bi
  • 51
  • 7
0

I think you need to add more information to your database definition. For instance, here's what my own database entry looks like in my settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'django',
        'USER': 'redacted',
        'PASSWORD': 'redacted',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

If you don't have a database user and password to enter in the fields marked redacted then you need to make sure you have the actual database created and psycopg2 installed.

souldeux
  • 3,615
  • 3
  • 23
  • 35
  • 1
    Note that deploying Django own server is a different kettle of fish: you have to manage security updates, iptables, log rotation, deployment (none of Heroku's nice git push tricks), etc. It's a little misleading to make it sound easier. – elithrar Jul 22 '15 at 10:31