我在pycharm中运行django,django能“正常”跑起来,因为运行之后并没有报错, 但是当我更改HttpResponse中的内容时,终端立马报错,并且终断Django执行。终端报错:TypeError: argument of type ‘WindowsPath’ is not iterable 解决方法: 我用的django3,模版路径配置: 'DIRS': [BASE_DIR / 'templates'],
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'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',
],
},
},
]
这个模板路径配置的问题,修改成 str(BASE_DIR / 'templates') 或者 os.path.join('BASE_DIR','templates')