I’ve got and as it seems common beginners problem

707    Asked by AshishSinha in Python , Asked on Jun 10, 2021

I’ve got and as it seems a common beginners problem.

I’am working on my first django project and when I set up my view I get a "TemplateDoesNotExist" error. I’ve spent lots of hours on this now - and I know there’s lots of topics on it but nothing helped me till now.

I hope I can supply all the information needed so an advanced django user can probably directly see what I am doing wrong.

I’m using the development server. and windows 7 & sqlite3.

this is the error I get:

TemplateDoesNotExist at /skates/
allsk8s.html
Request Method: GET
Request URL:    http://127.0.0.1:8000/skates/
Django Version: 1.4.3
Exception Type: TemplateDoesNotExist

in settings.py I set up the TEMPLATE_DIRS like this:

TEMPLATE_DIRS = (
    r'H:/netz2/skateprojekt/templates/',
)

the template loaders looks like this:

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

this is my view:

from django.shortcuts import render_to_response
from django.template import RequestContext
from sk8.models import Sk8
def AllSk8s(request):
    skates      = Sk8.objects.all().order_by('name')
    context     = {'skates':skates}
    return render_to_response('allsk8s.html', context, context_instance=RequestContext(request))

it should link to allsk8s.html - and it looks like it does but the file can not be found although it is definitely in the right folder. but as you can see:

Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
H:netz2skateprojekttemplatesallsk8s.html (File does not exist)

this is a part of my urls.py

    urlpatterns = patterns('',
         url(r'^admin/', include(admin.site.urls)),
         (r'^skates/$', 'sk8.views.AllSk8s'),
 )

and this is the system path:

H:netz2skateprojecttemplates

and in the templates folder is a file called allsk8s.html so as far as I understood it - this should work. I really hope somebody can help me cause this is the second time I ran into a problem like this and I can not figure out the problem.

Answered by Colin Payne

Your Answer

Interviews

Parent Categories