2đź‘Ť
For your first problem, are you sure you have Django in the PythonPath you have specified? On my server, the list in my PythonPath includes the directory containing the top-level django directory, which itself contains the bin, contrib, admin, core, etc. directories, in addition to __init__.py. (Also make sure your Apache user has read and execute permissions for these files and directories, although I’m sure this is obvious.) This is my setup:
<Location "/myapp">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE LogFileAnalyzer.settings
PythonDebug on
PythonPath "['/srv/www/dir_containing_django_dir', '/srv/www/myapp_dir'] + sys.path"
</Location>
Note that I’m using Location instead of Directory here, so your mileage may vary.
For your second problem, that sounds like a problem for mod_rewrite. See here. You can let the server append the slash you need automatically by defining a rewrite rule:
RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo$ foo/ [R]
Hope that helps.
1đź‘Ť
Alias /tech /srv/www/Tech
should be removed, and <Directory /srv/www/Tech>
should be converted to a location.
Remember, you’re not trying to get Apache to serve up your Python-files, you’re telling it to start a certain Python process when it hits a specific location.
Also, may I suggest that you use sub-domains instead of having your Django-app in a “folder” on your primary domain. It tends to simplify things in my opinion.
Also for your consideration is mod_wsgi
. I recently started using it for my Django apps, and they’ve taken a quantum leap forward in performance and stability 🙂
- [Django]-A production ready server to serve django on win32
- [Django]-Facebook Signed Request Decoding Incorrect Padding
- [Django]-How to select all objects not referenced in a many-to-many relationship
- [Django]-How to run Django units test with default and unmanaged database?
- [Django]-How do I get access to the request object when validating a django.contrib.comments form?
0đź‘Ť
Possibly not as helpful for mod_python problem, but really, mod_python is worst way to deploy Django (actually worst way to deploy any kind of Python at all).
Please, consider using mod_wsgi at least, it’s better for performance and a number of other reasons. Also, you’ll have excellent support from devs of that mod at #django on freenode.
Spawning/FastCGI is even better in the way you don’t even bother with Apache at all.