我有一個Django項目和結構如下,如何在本地運行的Django項目的Heroku
的Procfile
裏面,我有這樣的代碼,
web: gunicorn team-app.wsgi --log-file -
這是requirements.txt
,
appdirs==1.4.3
coreapi==2.3.0
coreschema==0.0.4
dj-database-url==0.4.2
Django==1.11
django-allauth==0.31.0
django-rest-auth==0.9.1
django-rest-swagger==2.1.2
djangorestframework==3.6.2
gunicorn==19.7.1
itypes==1.1.0
Jinja2==2.9.6
MarkupSafe==1.0
oauthlib==2.0.2
openapi-codec==1.3.1
packaging==16.8
pyparsing==2.2.0
python-openid==2.2.5
pytz==2017.2
requests==2.13.0
requests-oauthlib==0.8.0
simplejson==3.10.0
six==1.10.0
uritemplate==3.0.0
whitenoise==3.3.0
env
是本地安裝的virtualenv
。當我在root
文件夾,team-app
進入並運行命令heroku local web
,我得到以下錯誤,
所以,問題是ImportError: No module named team-app.wsgi
,我相信Procfile
的位置或有些東西是不正確的。該wsgi.py
文件中的users_groups
是如下,
"""
WSGI config for users_groups project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "users_groups.settings")
application = get_wsgi_application()
如果需要,我可以提供額外的信息。如何解決這個問題?
很難從截圖中看出來,但它看起來像'requirements.txt'和'Procfile'在一個子目錄中?他們[應該在](https://devcenter.heroku.com/articles/python-pip#the-basics)[root project directory](https://devcenter.heroku.com/articles/procfile)。它也看起來像你的整個Django應用程序在一個名爲'src /'的子目錄中;它可能也必須被提升到一個水平。通常我會用它作爲我的項目根目錄。你的Git倉庫是否處於'src /'級別或'team-app /'級別? – Chris
'1.'' requirements.txt和Procfile'均位於'team-app'的頂層。 '2.'這是正確的,整個Django應用程序在'src'文件夾內。我不相信這是一個問題,或者它是? '''''Git'生活在'team-app /'層面。 我爲這個問題提供了一個新的「項目結構」圖片,以便於理解。 – Arefe
當我第一次在Heroku上開始使用Django時,我記得不得不使用我的主Django目錄作爲我的項目根目錄。那是幾年前,所以也許它不再適用,但它是值得一試。嘗試將'Procfile'移動到'src /',然後'cd'到'src /',然後從那裏運行'heroku local web'('procfile'指'users_groups.wsgi')。 – Chris