2

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

1 Answer 1

0

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).

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

1 Comment

To set it in your local environment create a file named .env in your project home and add DATABASE_URL=postgres:///dbname where dbname is the name of your database of course. Then run syncdb via "foreman run python manage.py syncdb" so that it loads the environment variables.

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.