mod_python

2 views
Skip to first unread message

Dagur

unread,
Jul 22, 2005, 8:44:37 PM7/22/05
to django...@googlegroups.com
ok, I have mod_python and django installed, but the documentation
doesn't explain how I get these two to work together. Could someone
please tell me?

jocknerd

unread,
Jul 22, 2005, 9:00:18 PM7/22/05
to django...@googlegroups.com
You don't have to worry about them working together. Django takes care
of that for you. You just need to get mod_python running with Apache.

Jacob Kaplan-Moss

unread,
Jul 22, 2005, 10:03:51 PM7/22/05
to django...@googlegroups.com

Dagur

unread,
Jul 24, 2005, 12:54:02 PM7/24/05
to django...@googlegroups.com
why didn't I see that :-)


Anyway, I've tried everything but when i try to view my page in the
browser I get this:

EnvironmentError: Could not import DJANGO_SETTINGS_MODULE
'myproject.settings.main' (is it on sys.path?): No module named
myproject.settings.main

I edited ~/.bashrc both for root and my user (and my directory is in
sys.path) and restarted apache but nothing changes. I also tried
various settings in httpd.conf with no luck. I'm using fedora 4.

Matthew Marshall

unread,
Jul 24, 2005, 8:10:02 PM7/24/05
to django...@googlegroups.com
Try adding this to your apache config:
PythonPath sys.path+["/dir/where/django/is/"]

That did it for me.

MWM

Dagur Pall Ammendrup

unread,
Jul 25, 2005, 12:31:27 PM7/25/05
to django...@googlegroups.com
I did that but no luck, here's what i have:

<Location "/django">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings.main
PythonPath "[r'/home/dagur/workspace'] + sys.path"
PythonDebug On
</Location>

I'm using virtual hosts but only trying to use django for one of them.
Could that cause any problems?

Louis Zirkel

unread,
Jul 25, 2005, 3:07:18 PM7/25/05
to django...@googlegroups.com
On 7/25/05, Dagur Pall Ammendrup <dag...@gmail.com> wrote:
>
> I did that but no luck, here's what i have:
>
> <Location "/django">
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE myproject.settings.main
> PythonPath "[r'/home/dagur/workspace'] + sys.path"
> PythonDebug On
> </Location>
>
> I'm using virtual hosts but only trying to use django for one of them.
> Could that cause any problems?

I'm using virtual hosts on my installation, and I'm using django on a
couple and just straight html files and CGI and I've had no trouble so
far. I don't know if it matters or not, but I do NOT have the r
prefix on my path to my home directory. You might try removing that
to see if it's causing issues for some reason.

zzzirk

Andy Gimblett

unread,
Jul 26, 2005, 10:21:57 AM7/26/05
to django...@googlegroups.com
The 'r' really shouldn't make any difference, because mod_python just
eval()'s the string.

Dagur, are you using symlinks in /home/dagur/workspace/? mod_python
doesn't seem to want to follow symlinks, unfortunately...

It seems that if /home/dagur/workspace/myproject is a symlink to
somewhere else where myproject really lives, you get exactly the error
you've described. At least, I'm seeing the same thing in that
situation. Symlinks seem to work fine with "django-admin.py
runserver" but not apache/mod_python.

I've got "Option FollowSymlinks" set in apache.conf and I've checked
that that works for ordinary filesystem stuff - so it really looks to
me like the problem is with mod_python.

Does anyone know a way around this?

Thanks,

-Andy

--
Andy Gimblett
Computer Science Department
University of Wales Swansea
http://www.cs.swan.ac.uk/~csandy/

Andy Gimblett

unread,
Jul 26, 2005, 10:40:01 AM7/26/05
to django...@googlegroups.com
One other thought, Dagur: have you checked the permissions on the
myproject directory tree? Once you put things behind Apache, those
files need to be readable by whatever user's running Apache.
Sledgehammer: chmod -R a+rx /home/dagur/workspace/myproject

Cheers!

Dagur

unread,
Jul 26, 2005, 2:32:02 PM7/26/05
to django...@googlegroups.com
I'm not using symlinks and changing the permissions had no effect
unfortunately.

Maybe I should use WSGI? Has that been documented?

ToddG

unread,
Jul 26, 2005, 2:48:49 PM7/26/05
to django...@googlegroups.com
Have you asked the folks over here?:

http://modpython.org/pipermail/mod_python/

Sounds more like a mod_python issue than Django...

Reply all
Reply to author
Forward
0 new messages