2016-04-05 30 views
0

Uber simple app。私のviews.py:Djangoテンプレートのルックアップがアプリで表示されません

from django.http import HttpResponse 
from django.shortcuts import render 
from django.template import loader 

def index(request): 
    #return HttpResponse("Ready to turn some webpages into workflowies?") 
    template = loader.get_template('web/index.html') 

    return HttpResponse(template.render(context, request)) 

私はレンダリングする私の最初のテンプレートを取得しようとしている、と私は/

Template-loader postmortem 

Django tried loading these templates, in this order: 

Using engine django: 
django.template.loaders.app_directories.Loader: C:\utils\python\Python34\lib\site-packages\django\contrib\admin\templates\web\index.html (Source does not exist) 
django.template.loaders.app_directories.Loader: C:\utils\python\Python34\lib\site-packages\django\contrib\auth\templates\web\index.html (Source does not exist) 

しないのはなぜで

TemplateDoesNotExistを取得ローダーは/web/templates/index.htmlにテンプレートを見つけますか?

+0

IMOローダは '/テンプレート/ウェブ/ index.html' – Leonard2

+0

あなたがロードされている' 'ウェブ/ index.html''を探しますが、 '/ web/templates/index.html'が必要です。 'web'がアプリの場合、' settings.py'の 'INSTALLED_APPS'にそれを追加する必要があります。また、テンプレートのディレクトリ構造は 'web/templates/web/index.html'でなければなりません。 – AKS

答えて

1

/web/templates/web/index.htmlにindex.htmlを配置します。それが動作します。 settings.pyでのWebアプリケーションを追加してください

INSTALLED_APPS = [ 
'django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'web', 

]

関連する問題