未定义配置,请在heroku中部署

时间:2019-01-29 00:07:07

标签: django heroku

我正在尝试将我的django应用程序部署在heroku上,我也想在heroku上使用远程postgre。 dj-database-url是在我的需求文件中定义的,该文件也已在setting.py中导入。

requirements.txt

dj-database-url
gunicorn
Babel==2.6.0





settings.py

import dj_database_url
DATABASES = {

    'default': dj_database_url.config(
        default=config('DATABASE_URL')
    )
}

在部署过程中,我遇到以下错误,我在这里错过了什么?

"NameError: name 'config' is not defined"



File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
           return _bootstrap._gcd_import(name[level:], package, level)
         File "<frozen importlib._bootstrap>", line 994, in _gcd_import
         File "<frozen importlib._bootstrap>", line 971, in _find_and_load
         File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
         File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
         File "<frozen importlib._bootstrap_external>", line 678, in exec_module
         File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
         File "/tmp/build_b158ddc41a15ba9cab330674e51f4eff/restful01/settings.py", line 103, in <module>
           default=config('DATABASE_URL')
       NameError: name 'config' is not defined
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed

1 个答案:

答案 0 :(得分:0)

尝试DATABASES = {'default': dj_database_url.config()}