다음 장고 자습서 (https://docs.djangoproject.com/en/1.10/intro/reusable-apps/)를 따랐습니다. oldcity
이라는 프로젝트와 oldantwerp
이라는 앱이 있습니다. 앱은 상위 디렉토리 인 django-oldantwerp
에 있고 앱 디렉토리 자체는 서브 디렉토리 templates
을 가지고 있습니다. 내 프로젝트가 찾고있는 index.html
파일과 같이 위치하고 있습니다 :Django 패키지를 사용할 때 TemplateDoesNotExist
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'oldantwerp'
]
와 urls.py에서 :
django-oldantwerp>oldantwerp>templates>oldantwerp>index.html
내가 settings.py에서를 포함하여 내 프로젝트에이 응용 프로그램을 사용하려 합니다 (projec에서), 그래서 같은 :
urlpatterns = [
url(r'^oldantwerp/', include('oldantwerp.urls')),
url(r'^admin/', admin.site.urls),
]
내가 관리자 페이지로 이동, 모든 작품,하지만 인덱스 페이지를 열려고 할 때이 오류가 발생합니다 :
Template loader postmortem
Django tried loading these templates, in this order:
Using engine django:
* django.template.loaders.filesystem.Loader: /Users/Vincent/Apps/oldcity/templates/oldantwerp/index.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /Users/Vincent/Apps/oldcity/venv/lib/python3.4/site-packages/django/contrib/admin/templates/oldantwerp/index.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /Users/Vincent/Apps/oldcity/venv/lib/python3.4/site-packages/django/contrib/auth/templates/oldantwerp/index.html (Source does not exist)
그리고 그것은 또한 다른 파일을 검색하려고 : 나는 그런 생각하지 않기 때문에 place_list.html
, 이상하다
TemplateDoesNotExist at /oldantwerp/
그것은과 같이 index.html 파일을 찾기 위해 노력 말한다 파일.
무엇이 잘못 될 수 있습니까?
이것은 oldantwerp 폴더에 views.py의 코드
편집 : 난 그냥했을 때 모든 일을했다 :
class IndexView(generic.ListView):
template_name = 'oldantwerp/index.html'
context_object_name = 'places'
def get_queryset(self):
return Place.objects.order_by('id')[:]
EDIT 언급
어쩌면 가치 oldicty
프로젝트 폴더에 하위 폴더로 oldantwerp
폴더가 있습니다. 이 오류는 외부 패키지에서 구현 한 후에 만 발생합니다.
편집이 settings.py에서 내 템플릿 설정은 다음과 같습니다
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
우리에게주지하시기 바랍니다 귀하의 의견 ... –
내가 거기에 편집을 TEMPLATE_NAME합니다. – Vincent
[튜토리얼] (https://docs.djangoproject.com/en/1.10/intro/reusable-apps/)의 매니페스트 파일 (6 단계)에 템플릿을 포함 시켰습니까? 'import oldantwerp;를 입력하면, print (oldantwerp .__ file __)'를 코드에 추가하면 어떤 경로로 표시됩니까? – Alasdair