我正在尝试在heroku上部署我的django应用程序,我也想在heroku上使用remote 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发布于 2019-01-29 08:16:24
试试DATABASES = {'default': dj_database_url.config()}
https://stackoverflow.com/questions/54412074
复制相似问题