I can not render a page like this:

ImportError at / No module named 'django.templates' Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.9.7 Exception Type: ImportError Exception Value: No module named 'django.templates' Exception Location: /Users/Vadim/Documents/Python/testEnv/lib/python3.5/importlib/__init__.py in import_module, line 126 Python Executable: /Users/Vadim/Documents/Python/testEnv/bin/python Python Version: 3.5.1 Python Path: ['/Users/Vadim/Documents/Python/sites/dom_u_morya', '/Users/Vadim/Documents/Python/sites/dom_u_morya', '/Users/Vadim/Documents/Python/testEnv/lib/python35.zip', '/Users/Vadim/Documents/Python/testEnv/lib/python3.5', '/Users/Vadim/Documents/Python/testEnv/lib/python3.5/plat-darwin', '/Users/Vadim/Documents/Python/testEnv/lib/python3.5/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Users/Vadim/Documents/Python/testEnv/lib/python3.5/site-packages'] Server time: Вс, 5 Июн 2016 16:52:54 +0000 

views.py

 from django.shortcuts import render def houses_list(request): return render(request, "houses/houses_list.html") 

urls.py

 from django.conf.urls import url from django.contrib import admin from houses.views import houses_list urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', houses_list, name='home') ] 

Templates structure:

 templates houses houses_list.html 

settings.py

 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', ], }, }, ] 

    2 answers 2

    Based on the exception text, the django.templates module does not exist. There is django.template. You need to replace templates with template everywhere.

    • there is not a big problem if I change the folder name to the template, I have an action in views.py does not see the template and an appropriate error occurs. As a newbie Jange, explain where to change everywhere from django.templates to django.template in which files to search? Thanks in advance! - Vadim Vova
    • @VadimVova, you need to change the lines with the name of the module - change django.templates to django.template. Without renaming the directory. Also, the full path to the directory with templates must be added to the 'DIRS' array. Example - docs.djangoproject.com/en/1.8/ref/templates/api/… - m9_psy

    There was a similar error when changing the templates folder local for the pycharm application also changed the settings in settings.py is marked **

     TEMPLATES = [ { 'BACKEND': 'django.**template**.backends.django.DjangoTemplates', 'DIRS': [os.path.join(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', ], }, }, ]