私のdjangoプロジェクトのホームページを作成しようとしています。私はこのエラーを得続ける:/エラー例外at-loader.py行にテンプレートが存在しません43
TemplateDoesNotExist at/
home.html
Request Method: GET
Request URL: http://xtradev.local/
Django Version: 1.9
Exception Type: TemplateDoesNotExist
Exception Value:
home.html
Exception Location: /home/epic/EPIC/venv/lib/python2.7/site-packages/django/template/loader.py in get_template, line 43
Python Executable: /usr/bin/python
Python Version: 2.7.9
Python Path:
['/home/epic/EPIC/EPIC-PROJECT/EPIC-Django/EPIC_AR',
'/home/epic/EPIC/venv/lib/python2.7/site-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7']
Server time: Thu, 8 Dec 2016 14:04:41 +0000
私の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',
],
},
},
] [マイテンプレート]フォルダは、私のプロジェクトのフォルダにあるとhome.htmlが含まれ
これはloader.pyのコードです(ただし、何をしているか正確に要求しているわけではありません):
def get_template(template_name, dirs=_dirs_undefined, using=None):
"""
Loads and returns a template for the given name.
Raises TemplateDoesNotExist if no such template exists.
"""
chain = []
engines = _engine_list(using)
for engine in engines:
try:
# This is required for deprecating the dirs argument. Simply
# return engine.get_template(template_name) in Django 1.10.
if isinstance(engine, DjangoTemplates):
return engine.get_template(template_name, dirs)
elif dirs is not _dirs_undefined:
warnings.warn(
"Skipping template backend %s because its get_template "
"method doesn't support the dirs argument." % engine.name,
stacklevel=2)
else:
return engine.get_template(template_name)
except TemplateDoesNotExist as e:
chain.append(e)
raise TemplateDoesNotExist(template_name, chain=chain)
すべてが正しいと思われますが、私は何が見落としているのか分かりません。何か案は?
UPDATE: VIEWS.PY
from django.contrib.auth.models import User, Group
from django.shortcuts import render, HttpResponse
from rest_framework import filters
from rest_framework import viewsets
from serializers import UserSerializer, GroupSerializer
def home(request):
return render(request, ('home.html'))
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
URLS.PY
admin.site.site_header = 'EPIC.AR Administration'
urlpatterns = [
url(r'^$', 'EPIC_AR.views.home', name='Home'),
url(r'^admin/', admin.site.urls),
url(r'^api/1.0/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
]
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: /home/epic/EPIC/EPIC-PROJECT/EPIC-Django/EPIC_AR/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/venv/lib/python2.7/site-packages/suit/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/venv/lib/python2.7/site-packages/django/contrib/admin/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/venv/lib/python2.7/site-packages/django/contrib/auth/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/venv/lib/python2.7/site-packages/rest_framework/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/venv/lib/python2.7/site-packages/crispy_forms/templates/home.html (Source does not exist)
django.template.loaders.app_directories.Loader: /home/epic/EPIC/EPIC-PROJECT/EPIC-Django/EPIC_AR/home/templates/home.html (Source does not exist)
このエラーは、あなたのプロジェクトの全面に渡っているのですか? 1つのアプリケーションだけの場合は、このアプリケーションのビューを表示 –
さらにもう1つの質問、 'home.html'はどこに存在しますか? –
私は自分のプロジェクトを推測します - 私はホームページとして働くことを試みている1つのテンプレートしか持っていません。私は他の人がいません。私はアプリに入れてみましたが、どちらもうまくいきません。 home.htmlは、アプリケーションレベルのメインプロジェクトフォルダにあります。アプリ内ではなく、settings.pyと同じフォルダにはありません(以前はそのレベルでしたが)。別のものを試してみました。 – Nicoale