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

a 夏天 提交于 2020-02-28 17:24:50

问题


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:


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



来源:https://stackoverflow.com/questions/11618800/error-when-running-python-manage-py-syncdb-locally-but-no-error-when-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!