Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?

可紊 提交于 2019-11-27 00:21:05

问题


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 ?

Thanks.


回答1:


No. In fact, the file django/contrib/staticfiles/finders.py even checks for this and raises an ImproperlyConfigured exception when you do so:

"The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting"

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.

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).



来源:https://stackoverflow.com/questions/12161271/can-i-make-staticfiles-dir-same-as-static-root-in-django-1-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!