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

314    Asked by Unnatigautam in Java , Asked on Apr 7, 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

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

TTand 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.

One of the solutions to remove the error “django templatedoesnotexist” is you should add apps to settings.py. I assume you have an application named such as invoice then the solution to this is

INSTALLED_APPS = [
'invoice.apps.InoviceConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

Your Answer

Interviews

Parent Categories