简体   繁体   中英

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. 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. 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. 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

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. I'd like to invite you to see our django-on-dotcloud recipe:

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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