私はPyCharmに編集したHTMLを表示するためにレンダリングを使用してみましたが、私はアドレス入力されたとき:127.0.0.1:8000/index/
を、以下のTemplateDoesNotExist
の例外が登場:TemplateDoesNotExistエラー(Pythonの3.6.1に、Django 1.11.1、PyCharm)
/インデックス/ index.htmlを リクエストメソッドでTemplateDoesNotExist:GET リクエストURL:http://127.0.0.1:8000/index/ Djangoのバージョン:1.11.1 例外の種類:TemplateDoesNotExist 例外値:D: 例外場所のindex.html \ python3.6.1 \ lib \ site-packages \ django \ template \ lo get_templateでader.py、ライン25 Pythonの実行可能ファイル:D:\ python3.6.1 \ python.exe Pythonのバージョン:3.6.1 Pythonのパス:
[ 'C:\ Users \ユーザー管理者\ゲスト'、 「D D:¥python3.6.1¥DLL '、 ' D:¥python3.6.1¥lib '、 ' D:¥python3.6.1 '、 ' D:\ python3.6.1 \ libに\のsite-packages'] サーバー時間:金、午前三時30分58秒+ 0000`TemplateDoesNotExistで/インデックス/
settings.py 2017 6月2日:
ROOT_URLCONF = 'guest.urls'
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',
],
},
},
]
views.py:PyCharmの
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request,"index.html")
スクリーンショット:
私はStackOverflowの上で提供されるいくつかの方法を試してみましたが、彼らは動作しません。この例外は間違ったディレクトリによって引き起こされますか?どのように私はそのような状況に対処できますか?この時
間違ったdirs_によって引き起こされた...あなたはどんなdirsも持っていません: '' DIRS ':[] ' –
' collectstatics'をやったことがありますか? 'settings.py 'file?すべてのテンプレートを静的/テンプレートフォルダに入れましたか? –
@ PiyushS.Wanareあなたのコメントのすべての部分が間違っています。なぜcollectstaticはテンプレートと関係がありますか?なぜテンプレートは静的ディレクトリにありますか? –