我正在尝试通过github将django应用程序部署到heroku。
我收到以下错误 ImportError:没有名为settings.staging的模块
但我在“settings”文件夹下有“staging.py”文件。
我的github代码已开启:https://github.com/PramathaMadhavankutty/we_are_social
文件夹结构:
root folder/
manage.py
Procfile
settings/
staging.py
...
project-folder/
wsgi.py
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "we_are_social.settings")
application = get_wsgi_application()
Procfile
web: gunicorn we_are_social.wsgi:application
日志文件
2016-08-16T21:43:22.513176+00:00 app[web.1]: self.callable = self.load()
2016-08-16T21:43:22.513176+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-08-16T21:43:22.513177+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2016-08-16T21:43:22.513177+00:00 app[web.1]: return util.import_app(self.app_uri)
2016-08-16T21:43:22.513178+00:00 app[web.1]: application = get_wsgi_application()
2016-08-16T21:43:22.513178+00:00 app[web.1]: File "/app/we_are_social/wsgi.py", line 17, in <module>
2016-08-16T21:43:22.513178+00:00 app[web.1]: __import__(module)
2016-08-16T21:43:22.513179+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2016-08-16T21:43:22.513179+00:00 app[web.1]: django.setup()
2016-08-16T21:43:22.513180+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2016-08-16T21:43:22.513180+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
2016-08-16T21:43:22.513179+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
2016-08-16T21:43:22.513177+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 357, in import_app
2016-08-16T21:43:22.513182+00:00 app[web.1]: __import__(name)
2016-08-16T21:43:22.513180+00:00 app[web.1]: self._setup(name)
2016-08-16T21:43:22.513181+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup
2016-08-16T21:43:22.513181+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2016-08-16T21:43:22.513181+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2016-08-16T21:43:22.513182+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2016-08-16T21:43:22.513181+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/__init__.py", line 99, in __init__
2016-08-16T21:43:22.536787+00:00 app[web.1]: [2016-08-16 21:43:22 +0000] [3] [INFO] Reason: Worker failed to boot.
2016-08-16T21:43:22.513356+00:00 app[web.1]: [2016-08-16 21:43:22 +0000] [10] [INFO] Worker exiting (pid: 10)
2016-08-16T21:43:22.536539+00:00 app[web.1]: [2016-08-16 21:43:22 +0000] [3] [INFO] Shutting down: Master
2016-08-16T21:43:22.513183+00:00 app[web.1]: ImportError: No module named settings.staging
2016-08-16T21:45:48.063161+00:00 heroku[run.3662]: Process exited with status 0
2016-08-16T21:45:48.038116+00:00 heroku[run.3662]: State changed from up to complete
有人可以帮我解决这个问题吗?提前谢谢。
答案 0 :(得分:3)
只需在设置文件夹中创建一个空的__init__.py
文件(现在就错过了)。它将指示该文件夹是一个包,因此可以将其中的文件嵌入