/ app/index.htmlまたはindex.htmlにTemplateDoesNotExistというエラーがあります。 アプリ(子アプリ)がtestappと(親アプリ)であり、そしてアプリはindex.htmlにしている・urls.py・アプリのviews.py .urls.pyはtestappとのTemplateDoesNotExist at /何が間違っていますか?
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
views.py of app is
from django.shortcuts import render
def index(request):
return render(request, 'app/index.html')
urls.pyは
ですアプリでviews.pyのfrom django.conf.urls import include, url
from django.contrib import admin
from app.views import index
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^$', index, name='index'),
]
レンダリングの引数は、「index.htmlを」に変更しましたが、同じエラーhappens.Whatは間違っている?(ディレクトリを記述する方法?) どうすればこの問題を解決する必要がありますか? トレースバックは、あなたの持っている、その後設定
INSTALLED_APPS = ['your_app_name']
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
'django.template.context_processors.media'
],
},
},
]
下記のおsettings.pyをチェック
Traceback:
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/XXX/testapp/app/views.py" in index
5. return render(request, 'index.html')
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/shortcuts.py" in render
30. content = loader.render_to_string(template_name, context, request, using=using)
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
67. template = get_template(template_name, using=using)
File "/Users/XXX/myenv/lib/python3.5/site-packages/django/template/loader.py" in get_template
25. raise TemplateDoesNotExist(template_name, chain=chain)
Exception Type: TemplateDoesNotExist at/
Exception Value: index.html
thx ur comments.I ur codesを書きましたが、同じエラーが発生しました。他の問題はどう思いますか? – user8634222
設定ファイルにTEMPLATE_LOADERSがありますか? –
djangoのどのバージョンを使用しますか? –