So I'm trying to run multiple instances of Django on a server for now, one under /dev/
, one under /test/
, etc..
The web server is setting the correct SCRIPT_NAME
setting and I can serve pages, templates, the whole admin panel fine, except for static assets. Static assets are served by Django using WhiteNoise.
The application is supposed to use the value of SCRIPT_NAME
as the static URL, ie all static assets are served from the application root.
So far I've tried the following settings against the admin panel:
# SCRIPT_NAME = '/dev/' Set in env
# URL for static assets should be `/dev/`
STATIC_URL = '/' # Browser looks for static assets in `/`, drops script_name
STATIC_URL = None # Browser looks for static assets in `/`, drops script_name
STATIC_URL = `/dev/` # Browser looks for static assets in '/dev/dev/`
I'm wondering if I'm missing a setting here or if the problem might be elsewhere. Going by the docs I understand that STATIC_URL = '/'
should work?
Finally got a working config for running my app under /dev/
:
# SCRIPT_NAME = '/dev/' set from uwsgi, or use FORCE_SCRIPT_NAME
STATIC_URL = '/dev/'
WHITENOISE_STATIC_PREFIX = '/'
This seems to correctly prepend /dev/
to all static URLs, and makes whitenoise serve static assets from that directory (no subdir).
Not sure if this is the correct approach though?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With