Ankita
Ankita

Reputation: 197

Template Does not exist error

I'm new to Django. I want to display my home page that doesnt have any dynamic content other than admin login. I tried using direct_to_template generic view for this but on opening the url i get an error saying template doesnt exist.

from django.conf.urls import patterns, include, url
from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
from django.views.generic.simple import direct_to_template
admin.autodiscover()

  urlpatterns = patterns('',
  url(r'^$', direct_to_template, {'template': 'homepage.html'}),

  url(r'^STUDENT_REGISTERATION/', include('STUDENT_REGISTERATION.urls')),

  url(r'^admin/', include(admin.site.urls)),
  )`

the templates directory is located in /django-1.4/Project/templates.

Upvotes: 0

Views: 840

Answers (1)

Nicolas
Nicolas

Reputation: 21

Just as hells gate said, if you want to put templates to the root of your application (supposed to be Projects), you need to set TEMPLATE_DIRS. I usually use something like:

import os
TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(__file__), '..','templates'), # django 1.4
    os.path.join(os.path.dirname(__file__), 'templates'), # django 1.3
)

Or you can put your template files by creating a templates directory in any installed apps (with django.template.loaders.app_directories.Loader)

Upvotes: 2

Related Questions