简体   繁体   English

尝试部署django和wsgi无法导入我的设置文件-配置不正确/模块不存在

[英]trying to deploy django and wsgi can't import my settings file - improperly configured/module doesn't exist

I'm trying not to scream... 我正在努力不尖叫...

I am trying to deploy my django project and I can't seem to set the settings module correctly. 我正在尝试部署django项目,但似乎无法正确设置设置模块。 I have been googling and have come up empty. 我一直在谷歌搜索,空了出来。 I have deployed projects before(but am still a noob) and not had this problem so I can't figure it out. 我之前已经部署过项目(但仍然是菜鸟),并且没有这个问题,所以我无法弄清楚。 PLEASE HELP. 请帮忙。

I am deploying on dotcloud. 我正在dotcloud上部署。 FWIW I was going to deploy on heroku(until I realized that dotcloud is better suited for my project) and was having the same error. FWIW我打算在heroku上部署(直到我意识到dotcloud更适合我的项目),并且遇到相同的错误。 I just can't figure out what I'm doing wrong! 我只是不知道我在做什么错!

My settings file is located at: 我的设置文件位于:

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

wsgi.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")

Pathing issues can sometimes be a little tricky. 路径问题有时可能会有些棘手。 Could I suggest an alternate approach of starting your project on dotcloud by using a working project (something that deploys reliably) and then incrementally port your existing work into this base project. 我是否可以建议一种替代方法,通过使用工作项目(可靠部署的项目)在dotcloud上启动项目,然后将现有工作逐步移植到此基础项目中。 I'd like to invite you to see our django-on-dotcloud recipe: 我想邀请您查看我们的django-on-dotcloud食谱:

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

Using this project, you should be able to quickly iterate on something that deploys vs getting potentially hung up on a series of problems that may or may not be deployment related (we don't have visibility into your entire project, so its difficult to be definitive about what problem you're seeing. module locations, package locations, etc could be affecting the error). 使用这个项目,您应该能够快速迭代已部署的项目,而不是陷入可能与部署有关或可能与部署无关的一系列问题(我们无法了解整个项目,因此很难做到这一点)。确定您遇到的问题,模块位置,包装位置等可能会影响该错误)。

Using this, you can see how we've set-up the project and the location of the settings files. 使用此工具,您可以看到我们如何设置项目以及设置文件的位置。
https://github.com/dotcloud/django-on-dotcloud/blob/master/hellodjango/settings.py https://github.com/dotcloud/django-on-dotcloud/blob/master/hellodjango/settings.py

I realize that that the recipe is a little outdated and that it doesn't use the new settings files locations introduced with the more recent versions of django , however once you have a working project you can incrementally make it conform to whatever standards you'd like to move forward with. 我意识到该食谱有些过时了,并且没有使用django的最新版本引入的新设置文件位置,但是一旦您有了一个可行的项目,就可以逐步使其符合您的任何标准。喜欢前进。

If you're still having trouble, feel free to drop us a line at support@dotcloud.com and we can help take a closer look at what might not be working for you. 如果您仍然遇到问题,请随时给我们support@dotcloud.com ,我们可以帮助您仔细研究可能不适用于您的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM