3👍
You can use
WSGIScriptAlias /django1 /home/keratacon/www/django1/wsgi.py
WSGIScriptAlias /django2 /home/keratacon/www/django2/wsgi.py
in your apache+mod_wsgi config, assuming wsgi.py
is the name of your wsgi script.
0👍
This blog explains the solution (assuming that mod_wsgi is used, with nginx/uwsgi the solution is similar apparently in nginx/uwsgi this is not necessary).
The first parameter of WSGIScriptAlias – the /sub-url
will be stripped from the request url and the rest will go to your django app. If your Django app urls all start with /sub-url
(which are stripped by mod_wsgi), then you will not be able to show the views at those urls, unless you “re-insert” the /sub-url
to the request path part.
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
#the line below will re-append the sub-url to all urls
environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
#this one will make django think that it's the only thing running on the server
environ['SCRIPT_NAME'] = '' # my little addition to make it work
return _application(environ, start_response)
Also in your urls.py all urls must be prefixed with the sub-url of your interest.
Finally, the WSGIScriptAlias must be the same as your sub-url:
#the below line will "take-out" the sub-url and pass the rest
#to your wsgi script
WSGIScriptAlias /sub-url /path/to/wsgi_script
Where file /path/to/wsgi_script
must contain the definition of application
as shown in the first code snippet.
To make the “sub-url” setup explicit in Django, the equivalent request path patching would have to occur within the Django framework.
- [Django]-Django Media assets in Forms, how to defer/async JS assets?
- [Django]-What is the equivalent for assertDatabaseHas in Django
- [Django]-Django contenttype and string comparison