Django python 3.3模板不支持

2024-07-07 08:48:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我遵循“Pythondjango教程4高级视图和URL”on Youtube。在

当我键入http:/.../articles/all/时 上面写着TemplateDoesNotExist at /articles/all/

templates文件夹包含两个html文件,即article和articles

在视图.py在

from django.shortcuts import render_to_response
from article.models import Article
def articles(request):
    return render_to_response('articles.html',
                              {'articles':Article.objects.all()})

def article(request,article_id=1):
    return render_to_response('article.html',
                              {'article': Article.objects.get(id=article_id)})

在网址.py(摘自文章)

^{pr2}$

在网址.py(来自django_测试)

^{3}$

在/////////// 另外

TemplateDoesNotExist at /articles/all/
articles.html
Request Method: GET
Request URL:    .../articles/all/
Django Version: 1.6.2
Exception Type: TemplateDoesNotExist
Exception Value:    
articles.html
Exception Location: C:\Python33\lib\site-packages\django\template\loader.py in find_template, line 131
Python Executable:  C:\Python33\python.exe
Python Version: 3.3.4
Python Path:    
['c:\\Python33\\django_test',
 'C:\\WINDOWS\\SYSTEM32\\python33.zip',
 'C:\\Python33\\DLLs',
 'C:\\Python33\\lib',
 'C:\\Python33',
 'C:\\Python33\\lib\\site-packages']
Server time:    Fri, 14 Mar 2014 02:02:26 -0400

模板加载器后期分析

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
c:\Users\joseph\Documents\GitHub\Spring2014\CMP342\templates\WebContent\articles.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
C:\Python33\lib\site-packages\django\contrib\admin\templates\articles.html (File does not exist)
C:\Python33\lib\site-packages\django\contrib\auth\templates\articles.html (File does not exist)

我不知道为什么文件不存在


Tags: todjangopylibpackageshtmlarticlesite