views:

282

answers:

3

I just noted an annoying factor: Django requires either a restart of the server or CGI access to work. The first option is not feasible if you don't have access to the Apache server process. The second, as far as I know, is detrimental to performance, and in general the idea of running a CGI makes me uncomfortable.

I also recently saw a presentation titled "why I hate Django". Although I did not really shared most of the speaker's (a Flickr guy) points, this fact of re-starting the server sounded very annoying.

I would like to know your motivated experience in this regard. Should I continue working with Django and use it as a CGI, or favor another Python framework ? Is the CGI option that bad, and should I be concerned about it, or it's a viable option (for performance and scalability) ?

+5  A: 

Use the WSGI standard, through mod_wsgi. You don't have to restart Apache, merely update the mtime on the .wsgi file.

John Millikin
This assumes the server uses this apache module I guess.
Stefano Borini
How else would you hook up Django to Apache? Are you using something crazy like mod_python?
John Millikin
yes, I am. Please don't beat me :D
Stefano Borini
I won't beat you -- using mod_python is its own punishment. But you could solve your problems easily by using mod_wsgi instead. Here's some guides: < http://ericholscher.com/blog/2008/jul/8/setting-django-and-mod_wsgi/ >, < http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango >
John Millikin
thanks
Stefano Borini
Can we use mod_wsgi with non-Apache server?
jpartogi
No, mod_wsgi is an Apache module — although, confusingly, there is a ‘mod_wsgi’ for nginx which is an unrelated codebase. WSGI is the standard you write applications to; mod_wsgi is just glue to attach it to Apache. For a different web server, you'd use different glue, but the application itself would not need changing.
bobince
A: 

I usually don't restart the server, but force-reload the configuration. On an Ubuntu Hardy server, that is

sudo /etc/init.d/apache2 force-reload

and it's done almost immediately.

lbp
+1  A: 

For how to deal with source code reloading when using Apache/mod_wsgi, read:

http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html

http://blog.dscpl.com.au/2009/02/source-code-reloading-with-modwsgi-on.html

Documentation is more useful when it is read. ;-)

Graham Dumpleton