I’m trying to serve multiple django projects using only one instance on fcgi with Nginx.
I saw that django’s using the DJANGO_SETTINGS_MODULE to handle the correct project but I can not tell him to choose a specific project at runtime.
I tried ./manage.py –settings=SETTINGS but it is only when you start the process and it can’t be changed dynamically.
I also tried this on nginx:
location /foo {
fastcgi_split_path_info ^()(.*)$;
fastcgi_param DJANGO_SETTINGS_MODULE foo.settings;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
}
location /bar {
fastcgi_split_path_info ^()(.*)$;
fastcgi_param DJANGO_SETTINGS_MODULE bar.settings;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
}
But when I print the DJANGO_SETTINGS_MODULE, it is always at its default value.
So, anyone knows how to redirect a specific URL to a specific django project?
Thank you.
DJANGO_SETTINGS_MODULEcannot vary between requests. You’ll have to run one fastcgi server per site. For example foo on127.0.0.1:8080and bar on127.0.0.8081.