2014-04-08 1 views
0

settings.py에서 sqlite3을 실행하고이 데이터베이스의 이름을 database.db로 지정했습니다. index.html을이Django v1.5, TemplateDoesNotExist 오류

# -*- coding:UTF-8 -*- 
from django.shortcuts import render_to_response 

def oneView(request): 
    return render_to_response("index.html", {"content":"Hello World, from oneView"}) 

def anotherView(request): 
    return render_to_response("index.html", {"content":"Hello Again, from anotherView"}) 

내 디렉토리 블로그/blog_app/템플릿/index.html을처럼

from blog_app.views import oneView, anotherView 
from django.conf.urls import patterns, include, url 

urlpatterns = patterns('', 
    url(r'^one/$', oneView), 
    url(r'^another/$', anotherView), 
    # Examples: 
    # url(r'^$', 'django_project.views.home', name='home'), 
    # url(r'^django_project/', include('django_project.foo.urls')), 

    # Uncomment the admin/doc line below to enable admin documentation: 
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 

    # Uncomment the next line to enable the admin: 
    # url(r'^admin/', include(admin.site.urls)), 
) 

는 내 views.py 보인다. 왜냐하면 표준 설정 파일은 다음과 같이 말하고 있기 때문입니다 :

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader', 
    'django.template.loaders.app_directories.Loader', 
#  'django.template.loaders.eggs.Loader', 
) 

내 index.html 파일을 찾을 수 없다는 것이 이상하다고 생각합니다. 올바른 디렉토리를 찾지 못했습니까? 내가 어떤 아이디어 127.0.0.1:8000/one/ 또는 127.0.0.1:8000/another/

로 이동하려고 할 때

그럼에도 불구하고, 나는 단지 오류에 "/ 일 /에 TemplateDoesNotExist"를 얻을?

답변

2

SETTINGS_PATH = os.path.dirname(__file__) 
PROJECT PATH = os.path.join(SETTINGS_PATH, os.pardir) 
PROJECT_PATH = os.path.abspath(PROJECT_PATH) 
BLOG_PATH = os.path.join(PROJECT_PATH, "blog_app) 
TEMPLATES_PATH = os.path.join(BLOG_PATH, "templates") 

TEMPLATE_DIRS = (
    TEMPLATES_PATH, 
) 

오류 것은 일반적으로 잘못 나를 도우려고에 대한 템플릿 디렉토리를

+0

감사를 위해이 공간을 사용해서는 안되지만 익명의 사용자 이름과 함께 완벽한 답을 제공합니다. 이제 작동합니다. U 락 – Dolcens

+0

@Dolcens 대답은 귀하의 디렉토리 구조에 대한 나의 해석에 따른 것입니다 .. 작동하지 않는다면 장고 애플리케이션 – Ishan070692

+0

의 구조를 제공하십시오. upvote ..를 잊지 마세요. 스택 오버플로에 대해 조금 새로운 것 같습니다. – Ishan070692

0

정확한 오류 메시지는 무엇입니까? 그들은 사용하여 장고 응용 프로그램의 templates 폴더 (옆으로 manage.py), 응용 프로그램 다음라는 이름의 하위 폴더에 액세스 할 수 있습니다

import os 
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 
TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates') 
) 

: (디버그 정보는)

나는 템플릿에 대한 이러한 종류의 구성을 사용 설정된 경우 (귀하가 저희에게 제공 한 귀하의 사례가 아닙니다).

+0

감사를 구성 할 예정이다 당신의 settings.py에서이 같은 일을보십시오! os.path.join (BASE_DIR, 'templates') NameError : 'BASE_DIR'이름이 정의되어 있지 않습니다. – Dolcens

+0

이 줄이 없으면 전체 오류 메시지는 (현재) : 입니다. http://pastebin.com/qVSB5SJT – Dolcens

관련 문제