TemplateDoesNotExist at / index.html

Issue

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.

Solution

Add this in settings.py

TEMPLATE_DIRS = (
    PROJECT_PATH 
)

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

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

Answered By – user2879704

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published