图书

TemplateDoesNotExist

VIEW.PYfromdjango.shortcutsimportrenderfromdjango.shortcutsimportrender_to_responsefromdjangoimporttemplate#Createyourviewshere.fromdjango.,loaderdefindex(request):latest_poll_list=Poll.objects.all().order_by(‘-pub_date’)[:5]t=loader.get_template(‘index.html’)#t=open(‘/root/Django/mysite/polls/index.html’)c=Context({‘latest_poll_list’:latest_poll_list,})returnHttpResponse(t.render(c))#returnHttpResponse(“h2Hello.Youareatpollindex/h2”)——————————————————————————————-SETTINGS.PYTEMPLATES=[{‘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’,],},},]WSGI_APPLICATION=’mysite.wsgi.application’TEMPLATE_DIRS=(‘/root/Django/mysite/polls’,)———————————————-TemplateDoesNotExistat/polls/index.htmlRequestMethod:GETRequestURL:_template,line46PythonExecutable:/usr/bin/pythonPythonVersion:2.7.5PythonPath:[‘/root/Django/mysite’,’/usr/lib64/python2.7/site-packages/pip-1.5.6-py2.7.egg’,’/usr/lib64/python2.7/site-packages/setuptools-0.6c8-py2.7.egg’,’/usr/lib64/python2.7/site-packages/distribute-0.6.28-py2.7.egg’,’/usr/lib64/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg’,’/usr/lib64/python27.zip’,’/usr/lib64/python2.7′,’/usr/lib64/python2.7/plat-linux2′,’/usr/lib64/python2.7/lib-tk’,’/usr/lib64/python2.7/lib-old’,’/usr/lib64/python2.7/lib-dynload’,’/usr/lib64/python2.7/site-packages’,’/usr/lib64/python2.7/site-packages/PIL’,’/usr/lib64/python2.7/site-packages/gtk-2.0′]Servertime:Thu,4Jun201514:26:50+0000———nvironment:RequestMethod:GETRequestURL:(‘django.contrib.admin’,’django.contrib.auth’,’django.contrib.contenttypes’,’django.contrib.sessions’,’django.contrib.messages’,’django.contrib.staticfiles’,’polls’)InstalledMiddleware:(‘django.contrib.sessions.middleware.SessionMiddleware’,’django.middleware.common.CommonMiddleware’,’django.middleware.csrf.CsrfViewMiddleware’,’django.contrib.auth.middleware.AuthenticationMiddleware’,’django.contrib.auth.middleware.SessionAuthenticationMiddleware’,’django.contrib.messages.middleware.MessageMiddleware’,’django.middleware.clickjacking.XFrameOptionsMiddleware’,’django.middleware.security.SecurityMiddleware’)TemplateLoaderError:Djangotriedloadingthesetemplates,inthisorder:Usingloaderdjango.template.loaders.filesystem.Loader:Usingloaderdjango.template.loaders.app_directories.Loader:/usr/lib64/python2.7/site-packages/django/contrib/admin/templates/index.html(Filedoesnotexist)/usr/lib64/python2.7/site-packages/django/contrib/auth/templates/index.html(Filedoesnotexist)Traceback:File”/usr/lib64/python2.7/site-packages/django/core/handlers/base.py”inget_response132.response=wrapped_callback(request,*callback_args,**callback_kwargs)File”/root/Django/mysite/polls/views.py”inindex12.t=loader.get_template(‘index.html’)File”/usr/lib64/python2.7/site-packages/django/template/loader.py”inget_template46.raiseTemplateDoesNotExist(template_name)ExceptionType:TemplateDoesNotExistat/polls/ExceptionValue:index.html那位帮我看一下问题出在那里了?????

发表评论

电子邮件地址不会被公开。 必填项已用*标注

相关文章