【问题标题】:trying to deploy django and wsgi can't import my settings file - improperly configured/module doesn't exist尝试部署 django 和 wsgi 无法导入我的设置文件 - 配置不正确/模块不存在
【发布时间】:2014-07-31 23:09:00
【问题描述】:

我尽量不要尖叫......

我正在尝试部署我的 django 项目,但我似乎无法正确设置设置模块。我一直在谷歌搜索,结果空空如也。我以前部署过项目(但仍然是菜鸟)并且没有遇到这个问题,所以我无法弄清楚。请帮忙。

我在 dotcloud 上进行部署。 FWIW 我打算在 heroku 上部署(直到我意识到 dotcloud 更适合我的项目)并且遇到了同样的错误。我就是想不通我做错了什么!

我的设置文件位于:

/Users/<myname>/wheretoeat/wheretoeat/wheretoeat/settings.py

wsgi.py

import os
import sys

#sys.path.append('/Users/<myname>/wheretoeat/wheretoeat/wheretoeat')

from django.core.wsgi import get_wsgi_application
import sys
sys.path.append('/Users/<myname>/wheretoeat/wheretoeat/wheretoeat')
#sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),'wheretoeat')))
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

os.environ["DJANGO_SETTINGS_MODULE"] = "wheretoeat.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wheretoeat.settings")

【问题讨论】:

    标签: python django wsgi django-settings dotcloud


    【解决方案1】:

    路径问题有时会有点棘手。我能否建议一种替代方法,通过使用工作项目(可靠部署的项目)在 dotcloud 上启动项目,然后将现有工作逐步移植到此基础项目中。我想邀请你看看我们的 django-on-dotcloud 食谱:

    https://github.com/dotcloud/django-on-dotcloud

    使用此项目,您应该能够快速迭代已部署的内容,而不是陷入可能与部署相关或不相关的一系列问题(我们无法了解您的整个项目,因此很难确定您所看到的问题。模块位置、包位置等可能会影响错误)。

    使用它,您可以看到我们如何设置项目以及设置文件的位置。
    https://github.com/dotcloud/django-on-dotcloud/blob/master/hellodjango/settings.py

    我意识到这个配方有点过时了,并且它没有使用django 的更新版本引入的新设置文件位置,但是一旦你有一个工作项目,你可以逐步使其符合任何你想前进的标准。

    如果您仍然遇到问题,请随时通过support@dotcloud.com 给我们留言,我们可以帮助您仔细查看哪些可能不适合您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2015-08-25
      相关资源
      最近更新 更多