I’ve just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache.
I’m running OSX 10.5 and have the standard apache (which refuses to run python) and MAMP (which begrudgingly allows it in cgi-bin). The problem is that I’ve no idea which script to call, in the tutorial it was always localhost:8000/polls but I’ve no idea how that’s meant to map to a specific file.
Have I missed something blatantly obvious about what to do with a .htaccess file or does the tutorial not actually explain how to use it somewhere else?
You probably won’t find much joy using
.htaccessto configure Django through Apache (though I confess you probably could do it if you’re determined enough… but for production I suspect it will be more complicated than necessary). I develop and run Django in OS X, and it works quite seamlessly.The secret is that you must configure
httpd.confto pass requests to Django via one of three options:mod_wsgi(the most modern approach),mod_python(second best, but works fine on OS X’s Python 2.5),fastcgi(well… if you must to match your production environment).Django’s deployment docs have good advice and instruction for all three options.
If you are using the default OS X apache install, edit
/etc/apache2/httpd.confwith the directives found in the Django docs above. I can’t speak for MAMP, but if you build Apache from source (which is so easy on OS X I do wonder why anyone bothers with MAMP… my insecurities are showing), edit/usr/local/apache2/conf/httpd.conf.