简体   繁体   中英

Heroku+django: cannot find config vars locally

I am trying django on heroku, following the official tutorial and stuck at the creating celery and kombu tables locally step using python manage.py syncdb , getting following errors:

File "/my/virtual/path/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.

The problem is it cannot find the db I set for heroku by the config vars of heroku. When I run heroku config , it displays the DATABASE_URL of my app correctly, but when I try:

if 'DATABASE_URL' in os.environ

in python interpreter, it returns false . I also check, none of my config vars is in my os.environ . Shouldn't vars be added to it automatically? My previous steps are correct.

I searched and got a lot of solutions to detect the heroku db but they all are based on the assumption that I have the DATABASE_URL in my os.environ .

Could anyone point out where I went wrong? Any suggestion is appreciated. Thanks!

I believe the tutorial is missing some steps on how to run the app locally. If you want to sync the database locally, you should override the "default" DATABASE with the one you have on your machine. There is one similar answer in here with code sample.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM