django报错 No module named 'django.templates'

在使用django1.10.1的render模块时报错,No module named ‘django.templates’。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
ImportError at /polls/ss
No module named 'django.templates'
Request Method: GET
Request URL: http://192.168.1.152:8000/polls/ss
Django Version: 1.10.1
Exception Type: ImportError
Exception Value:
No module named 'django.templates'
Exception Location: /usr/local/lib/python3.4/importlib/__init__.py in import_module, line 109
Python Executable: /usr/local/bin/python3
Python Version: 3.4.4
Python Path:
['/root/django_coderselftrain',
'/root/django_coderselftrain',
'/usr/local/lib/python34.zip',
'/usr/local/lib/python3.4',
'/usr/local/lib/python3.4/plat-linux',
'/usr/local/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/site-packages']
During handling of the above exception ('django'), another exception occurred:

检查settings.py文件里面的TEMPLATES,No module named ‘django.templates’出错时的文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
TEMPLATES = [
{
'BACKEND': 'django.templates.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.templates.context_processors.debug',
'django.templates.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

将里面的templates字段全部改成template即可。这种情况跟用pycharm新建工程有关。