I must have multiple django projects living in the same root url such as this:
example.com/ # controlled by home django project example.com/project-2 # controlled by a separate django project example.com/project-3 # controlled by yet another django project
I'm already changing the LOGIN_REDIRECT_URL, etc. as recommended with this excellent answer, but I have found another hurdle. I'm really utilizing the same applications within the projects living at example.com/project-2 and example.com/project-3, which in turn causes some non-trivial trouble for connecting to content within a django project which have so far been solved with apparently hacky solutions.
For instance, you cant ever make reference to '/' in a template either in example.com/project-2 or example.com/project-3 revisit the main from the django project located at either of those Web addresses --- this can connect to the house django project at example.com. To obtain for this, I've designed a context processor that properly prepends the main link to the project with different custom configurations.py variable SCRIPT_Title: '' (for instance.com), '/project-2' (for instance.com/project-2), or '/project-3' (for instance.com/project-3). This really is all fine and good except you need to perform the same factor within the get_absolute_url functions. Before I understood it, I'd just switched a lot of code which was very multiple-use (by people apart from myself) into code which was not multiple-use whatsoever.
It is possible to method to accomplish exactly the same effect without needing to prepend absolute Web addresses using the SCRIPT_Title? Possibly something clever with apache or mod_wsgi configuration? I'm baffled and wishing someone might help...
My apache configuration for instance.com appears like this:
# redirect un-'/'-terminated urls to the '/'-terminated root urls RewriteEngine On RewriteRule /project-2$ /project-2/ [R=302,L] RewriteRule /project-3$ /project-3/ [R=302,L] # mod wsgi setup WSGIScriptAlias /project-2 /srv/project2/project-2.wsgi WSGIScriptAlias /project-3 /srv/project3/project-3.wsgi WSGIScriptAlias / /srv/project1/project-1.wsgi
You do not show how you are serving these projects out of your Apache configuration, which could have been helpful. But when you define them separate
WSGIScriptAlias directives, then
SCRIPT_NAME is instantly passed through for you personally, and Django takes it into consideration when curing and creating Web addresses.
WSGIScriptAlias /project-2 /srv/project2/project2.wsgi WSGIScriptAlias /project-3 /srv/project3/project3.wsgi WSGIScriptAlias / /srv/project1/project1.wsgi