我可以使 STATICFILES_DIR 与 Django 1.3 中的 STATIC_ROOT 相同吗? [英] Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?

查看:15
本文介绍了我可以使 STATICFILES_DIR 与 Django 1.3 中的 STATIC_ROOT 相同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Django 1.3,我意识到它有一个 collectstatic 命令可以将静态文件收集到 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 甚至会对此进行检查,并在您这样做时引发 ImproperlyConfigured 异常:

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 可以包含其他目录(不一定是应用程序目录)和静态文件,当您运行 collectstatic<时,这些静态文件将被收集到您的 STATIC_ROOT/em>.然后这些静态文件将由您的网络服务器提供,它们将从您的 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).

这篇关于我可以使 STATICFILES_DIR 与 Django 1.3 中的 STATIC_ROOT 相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆