Reputation: 371
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.
Upvotes: 0
Views: 571
Reputation:
theres a nice blog post i found as i wanted to figure out how to have multiple djnago projects on one server:
http://www.neuraladvance.com/2011/03/29/django-nginx-fastcgi-daemontools/
Upvotes: 0
Reputation: 308779
DJANGO_SETTINGS_MODULE
cannot vary between requests. You'll have to run one fastcgi server per site. For example foo on 127.0.0.1:8080
and bar on 127.0.0.8081
.
Upvotes: 1