我正在关注“Python DJango Tutorial 4高级视图和网址”on Youtube。
当我输入http:/.../articles/all/
时
它说TemplateDoesNotExist at /articles/all/
模板文件夹包含两个html文件,即文章和文章
views.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)})
urls.py(来自文章)
from django.conf.urls import patterns,include,url
urlpatterns = patterns('',
url(r'^all/$','article.views.articles'),
url(r'^get/(?P<article_id>\d+)/$','article.views.article'),
)
urls.py(来自django_test)
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
#(r'^aricles/',include('article.urls'))
# Examples:
# url(r'^$', 'django_test.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
(r'^articles/',include('article.urls')),
url(r'^admin/', include(admin.site.urls)),
#url(r'^hello/', 'article.views.hello'),
#url(r'^hello_template/', 'article.views.hello_template'),
)
/////////// 此外,
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
模板加载器postmortem
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)
我不知道为什么文件不存在tt