Hello, everyone. A little background for a problem first. I'm trying to write a tiny Django project for our corporate usage (my first one using Django). Every team has an account on a Linux box where we can host our web applications with URLs like: http:://server/~project/bin/app and every application is running with premissions of a corresponding "project" account.
I've tried to deploy a Django project with FastCGI and faced a problem with apps using absolute URL in their templates. In particular, login page to admin interface has an URL: http:://server/~project/bin/app/admin/ but the form on the page has action="/admin/". I've explored django.contrib.admin sources a bit and found that it uses request.path to retreive an absolute URL of the app. I've also tried to find a solution in the official documentation and this list archives, but all I found is about an URL of app relative to the root of the project but not an URL of the project itself. So, I've made a three-liner hack (wich actually breakes some rules mentioned in the official documentation). I've created a middleware class: class AbsolutePath : def process_request( self, request ) : request.path = request.META["SCRIPT_NAME"] + request.META["PATH_INFO"] and inserted it before all others. Fortunately, it even works :), though I don't completely understand why it do ;). I've expected to be required to prepend the project prefix to every urlpattern, but they should be left alone to work properly. It also produces not a very nice URL in my case, replacing "~" with "%7E" after a login, though it's looking Ok in the login page source. At last, the question: is there a less hacky solution to this problem, or my solution is Ok? -- Dmitry
signature.asc
Description: Digital signature