Django with Passenger
Asked Answered
U

1

8

I'm trying to get a trivial Django project working with Passenger on Dreamhost, following the instructions here

I've set up the directories exactly as in that tutorial, and ensured that django is on my PYTHONPATH (I can run python and type 'import django' without any errors). However, when I try to access the url in a browser, I get the following message: "An error occurred importing your passenger_wsgi.py". Here is the contents of my passenger_wsgi.py file:

import sys, os
sys.path.append("/path/to/web/root/") # I used the actual path in my file
os.environ['DJANGO_SETTINGS_MODULE'] = ‘myproject.settings’
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

However, when I put the following simple "Hello World" application in passenger_wsgi.py, it works as intended, suggesting Passenger is set up correctly:

def application(environ, start_response):
    write = start_response('200 OK', [('Content-type', 'text/plain')])
    return ["Hello, world!"]

What am I missing? Seems like some config issue.

Usage answered 12/3, 2009 at 6:26 Comment(0)
F
24

Are those fancy quotation marks also in your code?

os.environ['DJANGO_SETTINGS_MODULE'] = ‘myproject.settings’
                                       ^                  ^

If so, start by fixing them, as they cause a syntax error.

Ferritin answered 12/3, 2009 at 8:36 Comment(3)
Should I have made this a comment instead of an answer?Mischa
Thanks, that fixed it! Wow, I can't believe I made such a silly mistake. I just copied & pasted that from the tutorial site, and I guess the fancy quotes got copied along with it.Usage
This is why auto-smart-quotes must DIE!Kazan

© 2022 - 2024 — McMap. All rights reserved.