So I'm trying to run multiple instances of Django on a server for now, one under /dev/
, one under /test/
, etc..
所以我现在尝试在服务器上运行Django的多个实例,一个在/ dev /下,一个在/ test /下等等。
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.
Web服务器正在设置正确的SCRIPT_NAME设置,我可以提供页面,模板,整个管理面板,静态资产除外。 Django使用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.
应用程序应该使用SCRIPT_NAME的值作为静态URL,即从应用程序根目录提供所有静态资产。
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?
我想知道我是否错过了这里的设置,或者问题可能在其他地方。通过文档我明白STATIC_URL ='/'应该有效吗?
1 个解决方案
#1
0
Finally got a working config for running my app under /dev/
:
最后得到一个工作配置,用于在/ 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).
这似乎正确地将/ dev /前置到所有静态URL,并使whitenoise从该目录提供静态资源(无子目录)。
Not sure if this is the correct approach though?
不确定这是否是正确的方法?
#1
0
Finally got a working config for running my app under /dev/
:
最后得到一个工作配置,用于在/ 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).
这似乎正确地将/ dev /前置到所有静态URL,并使whitenoise从该目录提供静态资源(无子目录)。
Not sure if this is the correct approach though?
不确定这是否是正确的方法?