Making Django oblivious of the subfolder it's running in

I’m running two django projects from the same server. The first instance runs at port 8000, the second one runs at 8010. My server is configured so that requests for go to port 8000, requests for go to 8010. Now I want to make each instance of django oblivious of the fact that they are being run in subfolders. Otherwise I have to add “test/” or “rbp_website/” in front of every entry in my I’m very unexperienced with configuring servers, so any hints would be helpful.

Is this something that I do at the server level? Or is there a setting in Django that allows me to clarify this once?

Assuming that you’re running separate uwsgi containers for test and rbp_website, you handle this at the server / uwsgi layer.

In your uwsgi.ini file, add

mount = /test=test.wsgi:application
manage-script-name = true

This allows uwsgi to effectively strip off the initial /test from the referenced url within the application.

(Note, since nginx handles my static files directly, I do have separate static subdirectories in my nginx config pointing to the different directories. I don’t have uwsgi service static files.)


1 Like