Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (19.9k points)

Ive got an as it seems common beginners problem.

im working on my first django project and when I set up my view I get an "TemplateDoesNotExist" error. Ive spend lots of hours on this now - and I know theres 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 Im doing wrong.

im using the developement 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:\netz2\skateprojekt\templates\allsk8s.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:\netz2\skateproject\templates

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.

1 Answer

0 votes
by (25.1k points)

One of the solution to this problem is you should add apps to in settings.py. I assume you have an application named such as invoice then 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',

]

Related questions

Browse Categories

...