这里使用的是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