Django Static 配置

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

SITE_ROOT=os.path.join(os.path.abspath(os.path.dirname(__file__)),'..')
STATIC_ROOT = os.path.join(SITE_ROOT, 'static')
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
("css", os.path.join(STATIC_ROOT,'css')),
("js", os.path.join(STATIC_ROOT,'js')),
("img", os.path.join(STATIC_ROOT,'img')),
("fonts", os.path.join(STATIC_ROOT,'fonts')),
("data", os.path.join(STATIC_ROOT,'data')),
("media", os.path.join(STATIC_ROOT,'media')),
)

猜你喜欢

转载自www.cnblogs.com/hylinux/p/9504164.html