Friday, June 29, 2012

How to run a django app in a subdirectory alias

Hi,

I want to run a simple test project in a subdirectory alias on our development server. The basic setup is an nginx with a location that passes everything in a subdirectory to the wsgi application.

Django obviously does not understand that it runs in an subdirectory alias, which completely destroys URL generation and parsing.
I could not find any prefix-like setting in the docs and my google fu also did not help that much... so I'm asking here instead.

The only thing I did find was the setting FORCE_SCRIPT_NAME which at least fixes the URL generation. (see: http://docs.webfaction.com/software/django/config.html#mounting-a-django-application-on-a-subpath)
Sadly this does not fix the urlconf parsing, even though the mentioned site suggests that.

Is it possible to run a django application in a subdirectory alias and if so, how?

Thanks,
Sven

PS:
nginx config:
server {
        location /fancyprojectname/static {
                alias /srv/fancyprojectname/static;
        }

        location /fancyprojectname/ {
                uwsgi_pass unix://var/run/uwsgi/app/fancyprojectname/socket;
                include uwsgi_params;
        }
}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/DiyOjDLvUroJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment