可以在Django 1.3中将STATICFILES_DIR与STATIC_ROOT相同吗? [英] Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?
问题描述
我正在使用Django 1.3,我意识到它有一个收集静态命令来收集静态文件到 STATIC_ROOT 。这里我有一些其他全球文件需要使用 STATICFILES_DIR 来提供。
I'm using Django 1.3 and I realize it has a collectstatic command to collect static files into STATIC_ROOT. Here I have some other global files that need to be served using STATICFILES_DIR.
我可以让他们使用相同的目录吗?
Can I make them use the same dir ?
谢谢。
推荐答案
实际上,文件 django / contrib / staticfiles / finders.py
甚至检查这个,并引发一个不正确的配置
异常你这样做:
No. In fact, the file django/contrib/staticfiles/finders.py
even checks for this and raises an ImproperlyConfigured
exception when you do so:
STATICFILES_DIRS设置不应包含STATIC_ROOT设置
"The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting"
STATICFILES_DIRS
可以包含其他目录(不一定是应用程序目录)与静态文件,这些静态文件将被收集到您的 STATIC_ROOT
当您运行 collectstatic 。这些静态文件将由您的网络服务器提供,并从 STATIC_ROOT
中提供。
The STATICFILES_DIRS
can contain other directories (not necessarily app directories) with static files and these static files will be collected into your STATIC_ROOT
when you run collectstatic. These static files will then be served by your web server and they will be served from your STATIC_ROOT
.
如果您目前有您想要提供的 STATIC_ROOT
中的文件,那么您需要将其移动到另一个目录,并将其他目录放在 STATICFILES_DIRS
。您的 STATIC_ROOT
目录应为空,所有静态文件应收集到该目录中(即不应包含静态文件)。
If you have files currently in your STATIC_ROOT
that you wish to serve then you need to move these to a different directory and put that other directory in STATICFILES_DIRS
. Your STATIC_ROOT
directory should be empty and all static files should be collected into that directory (i.e., it should not already contain static files).
这篇关于可以在Django 1.3中将STATICFILES_DIR与STATIC_ROOT相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!