django官方文档关于STATIC_URL STATIC_ROOT STATICFILES_DORS collectstatic的描述
来源:互联网 发布:mac library文件夹在哪 编辑:程序博客网 时间:2024/05/24 23:13
https://docs.djangoproject.com/en/1.11/ref/settings/#std:setting-STATIC_ROOT
Static Files¶
Settings for django.contrib.staticfiles
.
STATIC_ROOT
¶
Default: None
The absolute path to the directory where collectstatic
will collect static files for deployment.
Example: "/var/www/example.com/static/"
If the staticfiles contrib app is enabled (as in the default project template), the collectstatic
management command will collect static files into this directory. See the how-to on managing static files for more details about usage.
Warning
This should be an initially empty destination directory for collecting your static files from their permanent locations into one directory for ease of deployment; it is not a place to store your static files permanently. You should do that in directories that will be found by staticfiles’s finders
, which by default, are 'static/'
app sub-directories and any directories you include in STATICFILES_DIRS
).
STATIC_URL
¶
Default: None
URL to use when referring to static files located in STATIC_ROOT
.
Example: "/static/"
or "http://static.example.com/"
If not None
, this will be used as the base path for asset definitions (the Media
class) and the staticfiles app.
It must end in a slash if set to a non-empty value.
You may need to configure these files to be served in development and will definitely need to do so in production.
STATICFILES_DIRS
¶
Default: []
(Empty list)
This setting defines the additional locations the staticfiles app will traverse if the FileSystemFinder
finder is enabled, e.g. if you use thecollectstatic
or findstatic
management command or use the static file serving view.
This should be set to a list of strings that contain full paths to your additional files directory(ies) e.g.:
STATICFILES_DIRS = [ "/home/special.polls.com/polls/static", "/home/polls.com/polls/static", "/opt/webfiles/common",]
Note that these paths should use Unix-style forward slashes, even on Windows (e.g."C:/Users/user/mysite/extra_static_content"
).
Prefixes (optional)¶
In case you want to refer to files in one of the locations with an additional namespace, you can optionally provide a prefix as (prefix,path)
tuples, e.g.:
STATICFILES_DIRS = [ # ... ("downloads", "/opt/webfiles/stats"),]
For example, assuming you have STATIC_URL
set to '/static/'
, the collectstatic
management command would collect the “stats” files in a 'downloads'
subdirectory of STATIC_ROOT
.
This would allow you to refer to the local file '/opt/webfiles/stats/polls_20101022.tar.gz'
with'/static/downloads/polls_20101022.tar.gz'
in your templates, e.g.:
<a href="{% static "downloads/polls_20101022.tar.gz" %}">
https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/
Management Commands¶
django.contrib.staticfiles
exposes three management commands.
collectstatic
¶
django-admin collectstatic
¶
Collects the static files into STATIC_ROOT
.
- django官方文档关于STATIC_URL STATIC_ROOT STATICFILES_DORS collectstatic的描述
- Django的STATIC_ROOT和STATIC_URL以及STATICFILES_DIRS
- Django - staticfiles,STATIC_ROOT, STATIC_URL,STATICFILES_DIRS
- django STATIC_URL STATIC_ROOT MEDIA_URL MEDIA_ROOT
- Django下MEDIA_ROOT, MEDIA_URL, STATIC_ROOT, STATIC_URL解惑
- django static_root static_url media_root mdia_url详解
- django static_root static_url media_root mdia_url详解
- django static_root static_url media_root mdia_url详解
- django static_root static_url media_root mdia_url详解
- django static_root static_url media_root mdia_url详解
- Django ====> 1.4版本静态文件路径设置--MEDIA_ROOT,MEDIA_URL, STATIC_ROOT, STATIC_URL学习
- Django的MEDIA_ROOT和STATIC_ROOT
- Django的MEDIA_ROOT和STATIC_ROOT
- Django的MEDIA_ROOT和STATIC_ROOT(转)
- 理解 django.contrib.staticfiles(collectstatic)
- Django settings 中的STATIC_URL
- django 官方文档地址
- django官方文档(Models)
- !analyze !teb命令错误提示
- centOs 下安装mysql
- TotoiseSVN的基本使用方法
- 月亮之眼_KEY
- hdu6198(矩阵快速幂+找规律)
- django官方文档关于STATIC_URL STATIC_ROOT STATICFILES_DORS collectstatic的描述
- stove项目总结
- POJ3616 Milking Time (dp)
- python实现线程池
- ImageLoader的省流量模式
- php实现图片缩放,超详细注释
- C++ vector 小记
- java手动生成验证码
- UNIX系统下的基于TCP协议的网络通信程序