Django setup HELP!

software development

#1

I’ve just tried to setup and upload my Django project to dreamhost, I really need to get it uploaded ASAP.

I’ve followed the guide here : http://stackoverflow.com/questions/10953695/update-django-1-4-and-python-2-7-3-with-virtualenv-on-dreamhost-with-passenger

Everything seemed to have worked fine upto the passenger_wsgi which gives me the error “An error occurred importing your passenger_wsgi.py” I’ve not had any experience with setting this kind of thing up before so could really use some help. My current wsgi file looks like so:

import sys, os
cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(cwd + '/projectname')

if sys.version < "2.7.5": os.execl("/home/lookeh/3dgiff.com/env/bin/python",
	"python2.7.5", *sys.argv)
	
sys.path.insert(0, '/home/<usr>/<domain.com>/evn/bin')
sys.path.insert(0, '/home/<usr>/<domain.com>/evn/lib/python2.7/site-packages/django')
sys.path.insert(0, '/home/<usr>/<domain.com>/evn/lib/python2.7/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = "projectname.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

is the shell user, and <domain.com> is my domain.

I’m really not sure where to go to fix this. I also have another query which is how to start my Django server, I’m currently doing to in Shell, using “python manage.py runserver” however if I exit Shell I assume this will quit the server also.

Any help would really be appreciated.

Regards


#2

Is the subdirectory of your domain called “env” or “evn”? I see both in your passenger_wsgi.py, and one of the two is almost certainly wrong. Is this just a transcription error, or is it like that in the real thing too?

What happens if you try to run passenger_wsgi.py from the command line? Any errors?


#3

It seems that you’re right! all my changes after this version I had it right but not on this one, I feel extremely stupid :frowning:

My static files however do not seem to load when debug is off, I’m not sure why this is though I’ve ran manage.py collectstatic and the files were copied to the expected location, should Django not be able to serve them from here as standard? I have the static location under home/usr/domain/static and the same location for media. Do you have any advice on what the issue could be? These locations are both set as the static_root and media_root respectively.

I’ve never used Django on a live environment before so I’m not really sure how to serve this media correctly.

Thanks for spotting my typo also, real help.


#4

That static location isn’t right. Put static files in /home/username/example.com/public (i.e, the directory that you’ve configured as your domain root in the DreamHost Panel), and Passenger will serve them directly from there.


#5

You’ve been really helpful, thanks a lot, if I could give you a gold star I would.