2016-04-05 28 views
0

Uber simple app. Benim views.py:Django şablonu araması, uygulamada görüntülenmiyor

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)) 

Ben işlemek için ilk şablon almaya çalışıyorum, ve G/

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) 

Neden değil

TemplateDoesNotExist almak yükleyici şablonu /web/templates/index.html içinde buldunuz mu?

+0

IMO yükleyici '/ templates/web/index.html' – Leonard2

+0

Sen yüklüyorsunuz' 'web/index.html'' arayacaktır ama bekliyoruz/web/templates/index.html'. Eğer web 'bir uygulama ise,' settings.py' içinde 'INSTALLED_APPS' içine eklemeniz gerekir. Ayrıca, şablonların dizin yapısı "web/templates/web/index.html" olmalıdır. – AKS

cevap

1

/.web/templates/web/index.html dizinine index.html yerleştirirsiniz. Çalışacak. settings.py olarak web uygulamasını ekleyin

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

]