views:

701

answers:

4

I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser.

Thanks for any suggestion and help!

+2  A: 

Is the application containing your Django project in your $PYTHONPATH (when Python is invoked in a server context)? For example, if your Django project is at /home/wwwuser/web/myproj, then /home/wwwuser/web should be in your $PYTHONPATH. You should set this in the script that loads the project when invoked from the web server.

mipadi
i should put PYTHONPATH '['/user/local/django/myproject'+sys.path]' in httpd.conf in apache?
xlione
or i should put something in django.wsgi?
xlione
i already had sys.path.append('/usr/local/django/myproject') in django.wsgi
xlione
how to add Django project path to PYTHONPATH ?Thanks
xlione
actually i can see in the debug infomationPython path includes ['/usr/local/django'], myproject's parent directory
xlione
+1  A: 

Just a guess, but unless you've explicitly made sure that your app is on PYTHONPATH, you should be specifying views in urls.py as myproject.myapp.views.functionname.

Otherwise:

  • check if you're setting PYTHONPATH, or what to. Your project directory should be in there.
  • if you enable the django admin (by uncommenting the lines that are there by default in urls.py), does that work?
michael
django admin not working too...
xlione
+1  A: 
  • All required env variables should be set in django.wsgi. You could compare the env declared in django.wsgi and the env of executing ./manage runserver and make sure they are same.
  • Furthermore, if there is another myapp package which could be found through PYTHONPATH before /usr/local/django/myapp, ImportError may be raised.
okm
A: 

I just had this problem. It went away when I added sys.path.append('/path/to/project') to my .wsgi file.

Joshua