Q:

Error when running "python manage.py syncdb" locally, but no error when running the same command via Heroku

I am new to Heroku and Django/Python.  I was hoping to find an answer for an issue I'm experiencing. I have been following the Getting Started tutorial in Heroku's Dev Center: https://devcenter.heroku.com/articles/django
Everything is working properly when running commands and pushing app code to Heroku.  For example, when I run the CLI command "heroku run python manage.py syncdb" everything works as expected with no errors.  However, when I try to run the same command locally, "python manage.py syncdb", I am getting the following output and error:
    Scotts-MacBook-Pro:bonavina scottklieberman$ python manage.py syncdb
    Traceback (most recent call last):
    File "manage.py", line 10, in <module>
    ...
    File "/Library/Python/2.7/site-  packages/django/db/backends/postgresql_psycopg2/base.py", line 162, in _cursor
    raise ImproperlyConfigured("You need to specify NAME in your Django settings file.")
    django.core.exceptions.ImproperlyConfigured: You need to specify NAME in your Django settings file.

I then went back and checked my settings.py file.  I am not specifying NAME in the settings file because I am using dj_database_url, as per the Heroku tutorial.  I am curious as to why this is failing locally (why it is requiring NAME), whereas it is compiling successfully on Heroku. Any help would be greatly appreciated. Let me know if there is any additional information you need to diagnose the issue.
Best,
Scott

A:

dj_database_url uses the value of the environment variable DATABASE_URL, which is set on Heroku but is probably not set in your local environment (unless you set it yourself).

