Python 使用django加载html模板失败

Python 使用django加载html模板失败,python,django,Python,Django,下面是我的文件夹结构 geoff settings.py urls.py //using this wsgi.py homepage migrations->folder _init_.py .....others here views.py index.html 在my geoff url//根url中 from homepage import views as homepage urlpatterns = [ url(r'^$'

下面是我的文件夹结构

  geoff
    settings.py
    urls.py  //using this
    wsgi.py

homepage
  migrations->folder
 _init_.py
 .....others here
 views.py
  index.html
在my geoff url//根url中

from homepage import views as homepage

urlpatterns = [
    url(r'^$', homepage.home, name = 'homepage')
]
现在,主页views.py

def home(request):
  template = loader.get_template('index.html')
   context = RequestContext(request, {
    'latest_poll_list': "new",
   })
  return HttpResponse(template.render(context))
上面的代码抛出了一个错误

TemplateDoesNotExist at 
homepage.html
有什么不对劲吗

更新SETTINGS.PY

INSTALLED_APPS = (
   'django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'homepage.apps.HomepageConfig'
)

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


如上所述,我已经在“设置”中包含了主页应用程序,但仍然无法工作。

您的模板设置应如下所示:

TEMPLATES = [
    {
        ####
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ####
   }
    ]
然后选择文件夹结构:

templates
    index.html
    ...other html
geoff
    settings.py
    urls.py  //using this
    wsgi.py

homepage
    migrations->folder
    _init_.py
    .....others here
    views.py

您的模板设置应如下所示:

TEMPLATES = [
    {
        ####
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ####
   }
    ]
然后选择文件夹结构:

templates
    index.html
    ...other html
geoff
    settings.py
    urls.py  //using this
    wsgi.py

homepage
    migrations->folder
    _init_.py
    .....others here
    views.py

请在您的设置中显示您的模板目录。py@SPSP我补充说it@Richard你能显示你的设置吗?py code在主页中创建一个模板/目录,并将index.html放入其中。请在设置中显示模板目录。py@SPSP我补充说it@Richard但它仍然不起作用。