您的位置:首页 > 编程语言 > Go语言

Django静态文件配置

2015-07-08 17:00 429 查看
这里使用的是Django 1.8.2

1.模板设置

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(__file__), '../templates').replace('\\', '/'), ],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]


2.static以及media设置

STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__), '../static/').replace('\\', '/'),
)

MEDIA_URL = '/upload/'
MEDIA_ROOT = (
os.path.join(os.path.dirname(__file__), '../upload/').replace('\\', '/')
)


3.引用

css引用

<link rel="stylesheet" href="/static/css/font-awesome.min.css">


模板引用

目录结构是

templates

- - test

- - - - index.html

return render_to_response('test/index.html', {})


注:图片的后台上传要安装一个app Pillow
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: