1、django.template.exceptions.TemplateDoesNotExist
django views后台程序render到某html文件报错,提示该html不存在,但用的绝对路径,虽然该html不与django程序同一个目录。
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates',BASE_DIR, 'C:/vue-admin-template-master/dist'],
'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',
],
},
},
]
解决办法:setting.py中在该DIRS中添加进html文件所在的路径。
2、GET chunk-libs.3dfb7769.css net::ERR_ABORTED 404 (Not Found)
找到html文件后又提示css,js等配置文件找不到
解决办法:setting.py中将配置文件路径添加进STATICFILES_DIRS中
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'login_register\\static'),
os.path.join(BASE_DIR, 'C:/vue-admin-template-master/dist/static'),
)
3、POST http:// 403 (Forbidden) send 报错,get请求可访问,POST则访问失败
解决办法:注释setting.py中的django.middleware.csrf.CsrfViewMiddleware