标签:额外 ssi 前缀 roc debug cat 返回 pytho style
创建django程序:django-admin startproject [name]
python manage.py runserver
#字符串
return HttpResponse(‘‘)
#自动找到模板路径下的html文件,读取内容并返回给用户
return render(request,‘[html]‘)
1.创建project
2.配置
-模板路径
TEMPLATES = [
{
‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
‘DIRS‘: [os.path.join(BASE_DIR, ‘template‘)],
‘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‘,
],
},
},
]
-静态文件路径
STATIC_URL = ‘/static/‘ #前缀
STATICFILES_DIRS=(
os.path.join(BASE_DIR, ‘pageStyle‘), #逗号很关键不然要报错
)
3.额外配置
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware‘,
‘django.contrib.sessions.middleware.SessionMiddleware‘,
‘django.middleware.common.CommonMiddleware‘,
#‘django.middleware.csrf.CsrfViewMiddleware‘,
‘django.contrib.auth.middleware.AuthenticationMiddleware‘,
‘django.contrib.messages.middleware.MessageMiddleware‘,
‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,
]
标签:额外 ssi 前缀 roc debug cat 返回 pytho style
原文地址:https://www.cnblogs.com/Oliva/p/12310581.html