Non-root routing with Django and Apache

I'm trying to get Django served by Apache, but I'd like it to be more flexible than the dumb way I've implemented it now. At the moment, my httpd_wsgi.conf has the following line:

WSGIScriptAlias / /Library/WebServer/Documents/acdc/apache/promotions.wsgi

      

In my urls.py project, I have this line:

url(r'^chicken/login/', 'login'),

      

If I type http://www.example.com/chicken/login into the address bar of my browser, I am redirected to the appropriate login function. And if all templates in urls.py are preceded by hens, then everything works fine.

However, I would like to switch the url where this application is deployed. So, for example, what if I wanted http://www.example.com/monkey/login to work? Right now I would have to change all my urls and all my links, which are unthinkable. It seems like it should be trivial if I change the WSGIScriptAlias:

WSGIScriptAlias /monkey/ /Library/WebServer/Documents/acdc/apache/promotions.wsgi

      

then I could just provide the urls:

url(r'^login/', 'login'),

      

and get rid of the clutch. The problem is that after an hour of trial and error and research, I cannot get it to work. Going to http://www.example.com/monkey/login using just the previous configuration gives me this Apache error in the log:

Target WSGI script not found or unable to stat: /Library/WebServer/Documents/acdc/apache/promotions.wsgilogin

      

so it looks like the "enter" route is just being added to the promotion.wsgi file that launches my Django application.

To summarize, I would like Apache to "swallow" parts of the url and feed the rest to match patterns to my patterns in urls.py. How to do it?

+3


source to share





All Articles