Django18初体验
1622 浏览 5 years, 11 months
17 Static file
版权声明: 转载请注明出处 http://www.codingsoho.com/Static files (CSS, JavaScript, Images)
https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "static_root")
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static_in_pro", "our_static"),
#os.path.join(BASE_DIR, "static_in_env"),
#'/var/www/static/',
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_in_env", "media_root")
- STATIC_URL : 服务器相对地址
- MEDIA_ROOT : 文件系统绝对路径,保存用户上传文件.
- MEDIA_URL: URL that handles the media served from MEDIA_ROOT. Make sure to use a trailing slash.
执行 python manage.py collectstatic,STATICFILES_DIRS中的文件将会拷贝到STATIC_ROOT中