views:

31

answers:

2

I just moved my site to an actual apache server (was developing locally before) and the site can't seem to find the urls.py file. basically what happens is that the homepage works, which is weird in itself considering that if i go to any url, e.g. website/about/, i will get a 404 error with text {'path': u'about/'}.

I tried ROOT_URLCONF set to mysite.urls and just urls, and if i move the urls.py it will continue to behave the same way.

I don't know if its related but I also can't seem to access my site media folder, it seems as though the server is still reading it in its old path, but the settings.py file is correct. (tried restarting apache, rebooting server, etc..)

+1  A: 

I would be more worried about it not finding the media directory, that's pure apache. If that part of the equation isn't working, nothing else will. Work with apache's httpd.conf until you can browse to the media directory correctly first.

Update:

I copied in my working conf file and substituted your values. Your django.root might need to be "" or not set at all, as I've found that it shouldn't end with a /:

<Location "/">
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE fikdusite.settings
  PythonOption django.root ""
  PythonDebug On
  PythonPath "['/django_apps/', '/django_apps/fikdusite/'] + sys.path"
</Location>

And make sure that the .profile of the user that apache runs your site as, has:

export DJANGO_SETTINGS_MODULE='fikdusite.settings'
export PYTHONPATH=$PYTHONPATH:/django_apps:/django_apps/fikdusite
eruciform
Have been playing around with Apache but it's not showing me any love. My app is located in /django_apps/firstapp/. My httpd.conf looks like:`<Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE fikdusite.settings PythonOption django.root / PythonDebug On PythonPath "['/django_apps/', '/django_apps/fikdusite/'] + sys.path"</Location>`Any suggestions as to what I might be doing wrong? **EDIT: I also can't seem to get the code formatting or line breaks to work :(**
ergelo
updated. might be `django.root`
eruciform
adding the exports to the profile did the trick! thanks a lot!! (the media isn't working because I'm still trying to configure the separate media handling server)
ergelo
no problem, good luck! :-)
eruciform
+1  A: 

First, don't use mod_python, use mod_wsgi.

Secondly, don't forget that you need to restart Apache every time you make a code change in Django.

Daniel Roseman
I moved to mod_wsgi, but I had the same problem. I followed the advice from the previous answer and it worked for mod_wsgi as well.
ergelo
If you had issues when you moved to mod_wsgi, it may be because you still had mod_python loaded. The .profile settings will not work with mod_wsgi either. Also, with mod_wsgi you don't need to restart the whole of Apache every time you make a code change if using daemon mode. In daemon mode you can just touch the WSGI script file. See 'http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode'.
Graham Dumpleton