송요섭 송요섭 - 3 months ago 20
Python Question

TemplateDoesNotExist at / index.html

I have some problem in my Django project.

I am new to make web application with django. please help me.

So,

This is my directory path,

-lullabyluna
----app_index
------------admin.py
------------index.html
------------__init__.py
------------migtations
------------models.py
------------tests.py
------------views.py
----index.html(I wonder this files path.)
----lullabyluna
------------__init__.py
------------settings.py
------------url.py
------------wsgi.py
----manage.py
----static


and my settings.py file include the:

INSTALLED_APPS = (


'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app_index',
)


and this is my url.py file

from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns('app_index.views',
# Examples:
url(r'^$', 'home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)


and finally this is my app_index/views.py

from django.template import RequestContext
from django.shortcuts import render_to_response

def home(request):
return render_to_response('index.html',{},context_instance=RequestContext(request))


so, I want to know where is the right "index.html" file's path.

Answer

Add this in settings.py

TEMPLATE_DIRS = (
    PROJECT_PATH 
)

(or) move your index.html to templates folder & do this,

TEMPLATE_DIRS = (
    PROJECT_PATH + '/templates/',
)