3

I'm following the Heroku Django tutorial. I believe I followed it exactly. I ran no additional commands besides what they asked for.

However, when I get to the part where I sync the Celery and Kombu tables (under the "Running a Worker" section), I get a bug.

Typing in their command python hellodjango/manage.py syncdb, gives me the following:

...
File "/Users/Alex/Coding/getcelery/venv/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, in complain
    raise ImproperlyConfigured("You haven't set the database ENGINE setting yet.")
django.core.exceptions.ImproperlyConfigured: You haven't set the database ENGINE setting yet.

Anybody run into this problem before? Should I be doing something that's not explicit in the tutorial?

Any hints would be greatly appreciated!

Alexandre
  • 2,073
  • 4
  • 21
  • 24
  • hey, I met the same problem creating tables locally. I find you use sqlite3 as local db instead, but would that create conflict with the remote? because heroku remote is using postgresql still. – Yulong Jun 18 '12 at 15:46

2 Answers2

1

Your output is from running the syncdb locally. Enabling the database addon will set DATABASE_URL in your config, and hence the environment of the dynos (see heroku config). What it won't do is set DATABASE_URL locally - you'll need to do that yourself (or sort some other local database)

Kristian Glass
  • 37,325
  • 7
  • 45
  • 73
  • I added a sqlite database locally (I think that's all I did), configured it locally, and everything started working! Thanks – Alexandre Apr 17 '12 at 18:52
0

Its likely because your DATABASE dictionary is undefined. Can you attempt to add this code which should read your database from the environment variable then the CELERY db can be setup from it:

import os
import sys
import urlparse

# Register database schemes in URLs.
urlparse.uses_netloc.append('postgres')
urlparse.uses_netloc.append('mysql')

try:

    # Check to make sure DATABASES is set in settings.py file.
    # If not default to {}

    if 'DATABASES' not in locals():
        DATABASES = {}

    if 'DATABASE_URL' in os.environ:
        url = urlparse.urlparse(os.environ['DATABASE_URL'])

        # Ensure default database exists.
        DATABASES['default'] = DATABASES.get('default', {})

        # Update with environment configuration.
        DATABASES['default'].update({
            'NAME': url.path[1:],
            'USER': url.username,
            'PASSWORD': url.password,
            'HOST': url.hostname,
            'PORT': url.port,
        })
        if url.scheme == 'postgres':
            DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

        if url.scheme == 'mysql':
            DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
except Exception:
    print 'Unexpected error:', sys.exc_info()
CraigKerstiens
  • 5,906
  • 1
  • 25
  • 28
  • I tried adding this code to `settings.py`, but I still get the exact same error when doing syncdb. The tutorial says "When you deploy a Django application, the compile process appends [the code snippet above] to your settings.py to use the DATABASE_URL environment variable". – Alexandre Mar 05 '12 at 20:54
  • any clues on the "haven't set the database ENGINE setting" (updated) bug above? Have you ever managed to run through this tutorial successfully? Any help you can give would be wonderful – Alexandre Mar 06 '12 at 20:49