Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

python - Django Template does not exist error, although it shows 'file exists'

I am not able to render any html pages in Django 1.7. My 'index.html' is in 'project/seatalloc/templates/index.html' and my view.py in project/seatalloc/views.py looks like:

 def index(request):
       return render(request, 'index.html', dirs=('templates',)) 

project/project/settings.py has templates dirs set:

TEMPLATE_DIRS = (
    '/Users/Palak/Desktop/academics/sem3/cs251/lab11/project/seatalloc/templates',

)

urls.py:

urlpatterns = patterns('',
    url(r'^seatalloc/', include('seatalloc.urls')),
    url(r'^admin/', include(admin.site.urls)),
)

Template loader

I have tried to follow the documentation strictly, yet can't figure out if Django detects the file, why am I getting TemplateDoesNotExist at /seatalloc/ error. I am new to Django, could someone please help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If - as in your case - you get a TemplateDoesNotExist error and the debug page states "File exists" next to the template in question this usually (always?) means this template refers to another template that can't be found.

In your case, index.html contains a statement ({% extends %}, {% include %}, ... ) referring to another template Django cannot find. Unfortunately, as of Django 1.8.3, the debug page always names the base template, not the one Django can't find.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...